{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":4477,"databundleVersionId":44220,"sourceType":"competition"}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nimport zipfile\nimport glob\nimport numpy as np\nimport pandas as pd\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.utils.data import Dataset, DataLoader\nfrom sklearn.model_selection import train_test_split\nfrom tqdm import tqdm\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:07:16.172818Z","iopub.execute_input":"2025-06-15T02:07:16.173129Z","iopub.status.idle":"2025-06-15T02:07:22.682973Z","shell.execute_reply.started":"2025-06-15T02:07:16.173099Z","shell.execute_reply":"2025-06-15T02:07:22.681705Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 1. Opt parametreleri (Eğitimde kullanılan değerler)\n# --------------------------\nclass Opt:\n    in_channels = 32\n    in_len = 1000\n    batch_size = 64\n    n_cpu = 4\n    lr = 0.001\n    n_epochs = 50   # kaç epoch ile eğitilecek\nopt = Opt()\n\n\n\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:07:22.684114Z","iopub.execute_input":"2025-06-15T02:07:22.684549Z","iopub.status.idle":"2025-06-15T02:07:22.693188Z","shell.execute_reply.started":"2025-06-15T02:07:22.684525Z","shell.execute_reply":"2025-06-15T02:07:22.692043Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# ======================\n# 1. VERI HAZIRLIK\n# ======================\n\nbase_path = '/kaggle/input/grasp-and-lift-eeg-detection/'\ntrain_zip_path = base_path + 'train.zip'\ntest_zip_path = base_path + 'test.zip'\n\nwith zipfile.ZipFile(train_zip_path, 'r') as zip_ref:\n    zip_ref.extractall('./train')\nwith zipfile.ZipFile(test_zip_path, 'r') as zip_ref:\n    zip_ref.extractall('./test')\n\ntrain_data_path = './train/train/'\ntest_data_path = './test/test/'\n\ntrain_data_files = glob.glob(train_data_path + '*_data.csv')[:10]  # Dosya sayısını sınırladık\ntrain_events_files = glob.glob(train_data_path + '*_events.csv')[:10]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:07:22.695486Z","iopub.execute_input":"2025-06-15T02:07:22.695896Z","iopub.status.idle":"2025-06-15T02:07:58.501638Z","shell.execute_reply.started":"2025-06-15T02:07:22.695867Z","shell.execute_reply":"2025-06-15T02:07:58.500713Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def get_subject_series(filename):\n    base = filename.split('/')[-1]\n    parts = base.split('_')\n    subj = int(parts[0].replace('subj',''))\n    series = int(parts[1].replace('series',''))\n    return subj, series\n\ntrain_data_dict, train_events_dict = {}, {}\nfor f in train_data_files:\n    subj, series = get_subject_series(f)\n    train_data_dict[(subj,series)] = pd.read_csv(f, index_col=0)\nfor f in train_events_files:\n    subj, series = get_subject_series(f)\n    train_events_dict[(subj,series)] = pd.read_csv(f, index_col=0)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:07:58.505131Z","iopub.execute_input":"2025-06-15T02:07:58.505392Z","iopub.status.idle":"2025-06-15T02:08:07.079782Z","shell.execute_reply.started":"2025-06-15T02:07:58.505371Z","shell.execute_reply":"2025-06-15T02:08:07.078781Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Basit pencereleme ile örnek oluşturma\n\ndef extract_features_and_labels(data_df, label_df, window_size=1000, step_size=100):\n    X, y = [], []\n    for start in range(0, len(data_df)-window_size, step_size):\n        end = start + window_size\n        window = data_df.iloc[start:end].values.T  # (features, time)\n        labels = label_df.iloc[end-1].values.astype(np.float32)\n        X.append(window)\n        y.append(labels)\n    return X, y\n\n\nX_list, y_list = [], []\nfor key in train_data_dict:\n    if key in train_events_dict:\n        x, y = extract_features_and_labels(train_data_dict[key], train_events_dict[key])\n        X_list.extend(x)\n        y_list.extend(y)\n\nX = np.stack(X_list).astype(np.float32)  # (N, channels, time)\ny = np.stack(y_list).astype(np.float32)  # (N, 6)\n\nX_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.1, random_state=42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:08:07.080626Z","iopub.execute_input":"2025-06-15T02:08:07.081238Z","iopub.status.idle":"2025-06-15T02:08:07.783653Z","shell.execute_reply.started":"2025-06-15T02:08:07.081213Z","shell.execute_reply":"2025-06-15T02:08:07.782652Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# --------------------------\n# 2. Dataset Tanımı\n# --------------------------\nclass EEGDataset(Dataset):\n    def __init__(self, data, labels=None, window_size=opt.in_len, train=True):\n        # data: (channels, total_time)\n        self.data = data\n        self.labels = labels\n        self.window_size = window_size\n        self.train = train\n\n        self.total_len = data.shape[1]\n        self.samples = self.total_len - window_size + 1\n\n    def __len__(self):\n        return self.samples\n\n    def __getitem__(self, idx):\n        x = self.data[:, idx:idx+self.window_size]  # (channels, window_size)\n        if self.train:\n            y = self.labels[idx+self.window_size-1]  # son zaman noktasındaki label\n            return torch.tensor(x, dtype=torch.float32), torch.tensor(y, dtype=torch.float32)\n        else:\n            return torch.tensor(x, dtype=torch.float32)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:08:07.784805Z","iopub.execute_input":"2025-06-15T02:08:07.785224Z","iopub.status.idle":"2025-06-15T02:08:07.798271Z","shell.execute_reply.started":"2025-06-15T02:08:07.785187Z","shell.execute_reply":"2025-06-15T02:08:07.796926Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# --------------------------\n# 3. Model Tanımı (CNN + BiLSTM)\n# --------------------------\nclass EEGNet(nn.Module):\n    def __init__(self):\n        super(EEGNet, self).__init__()\n        self.cnn = nn.Sequential(\n            nn.Conv1d(opt.in_channels, 64, kernel_size=7, padding=3),\n            nn.BatchNorm1d(64),\n            nn.ReLU(),\n            nn.Conv1d(64, 128, kernel_size=5, padding=2),\n            nn.BatchNorm1d(128),\n            nn.ReLU(),\n            nn.Conv1d(128, 128, kernel_size=3, padding=1),\n            nn.BatchNorm1d(128),\n            nn.ReLU()\n        )\n        self.lstm = nn.LSTM(input_size=128, hidden_size=128, num_layers=1,\n                            batch_first=True, bidirectional=True)\n        self.classifier = nn.Sequential(\n            nn.Linear(128*2, 64),\n            nn.ReLU(),\n            nn.Linear(64, 6),\n            nn.Sigmoid()\n        )\n\n    def forward(self, x):\n        # x: (batch, channels, time)\n        x = self.cnn(x)  # (batch, 128, time)\n        x = x.permute(0, 2, 1)  # (batch, time, features)\n        out, _ = self.lstm(x)   # (batch, time, hidden*2)\n        out = out[:, -1, :]     # son zaman adımı\n        out = self.classifier(out)\n        return out","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:08:07.799408Z","iopub.execute_input":"2025-06-15T02:08:07.800169Z","iopub.status.idle":"2025-06-15T02:08:07.819034Z","shell.execute_reply.started":"2025-06-15T02:08:07.800130Z","shell.execute_reply":"2025-06-15T02:08:07.817969Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# --------------------------\n# 4. Eğitim ve Doğrulama Verilerini Hazırla\n# --------------------------\n# Eğitim verisini yükle, normalize et ve böl\n# (örnek olarak burada rastgele veri kullanıyorum, kendi verinle değiştir)\nnp.random.seed(42)\ntotal_time = 15000\ntrain_data = np.random.randn(opt.in_channels, total_time).astype(np.float32)\ntrain_labels = np.random.randint(0, 2, size=(total_time, 6)).astype(np.float32)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:08:07.823223Z","iopub.execute_input":"2025-06-15T02:08:07.823531Z","iopub.status.idle":"2025-06-15T02:08:07.860610Z","shell.execute_reply.started":"2025-06-15T02:08:07.823508Z","shell.execute_reply":"2025-06-15T02:08:07.859713Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Normalize et (kanal bazlı)\nmean = train_data.mean(axis=1, keepdims=True)\nstd = train_data.std(axis=1, keepdims=True)\ntrain_data = (train_data - mean) / (std + 1e-7)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:08:07.861590Z","iopub.execute_input":"2025-06-15T02:08:07.861887Z","iopub.status.idle":"2025-06-15T02:08:07.875609Z","shell.execute_reply.started":"2025-06-15T02:08:07.861860Z","shell.execute_reply":"2025-06-15T02:08:07.874735Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Veri setini train / val olarak ayır\nval_ratio = 0.2\nval_start = int(total_time * (1 - val_ratio))\n\ntrain_dataset = EEGDataset(train_data[:, :val_start], train_labels[:val_start], train=True)\nval_dataset = EEGDataset(train_data[:, val_start:], train_labels[val_start:], train=True)\n\ntrain_loader = DataLoader(train_dataset, batch_size=opt.batch_size, shuffle=True, num_workers=opt.n_cpu)\nval_loader = DataLoader(val_dataset, batch_size=opt.batch_size, shuffle=False, num_workers=opt.n_cpu)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:08:07.876592Z","iopub.execute_input":"2025-06-15T02:08:07.876912Z","iopub.status.idle":"2025-06-15T02:08:07.891783Z","shell.execute_reply.started":"2025-06-15T02:08:07.876884Z","shell.execute_reply":"2025-06-15T02:08:07.890827Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# --------------------------\n# 5. Model, Kayıp ve Optimizasyon\n# --------------------------\nmodel = EEGNet().to(device)\ncriterion = nn.BCELoss()\noptimizer = torch.optim.Adam(model.parameters(), lr=opt.lr)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:08:07.892826Z","iopub.execute_input":"2025-06-15T02:08:07.893168Z","iopub.status.idle":"2025-06-15T02:08:11.699138Z","shell.execute_reply.started":"2025-06-15T02:08:07.893142Z","shell.execute_reply":"2025-06-15T02:08:11.698321Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nfrom tqdm import tqdm\n\npatience = 15\nbest_val_loss = float('inf')\ncounter = 0\n\ntrain_losses = []\nval_losses = []\ntrain_accuracies = []\nval_accuracies = []\n\nfor epoch in range(opt.n_epochs):\n    model.train()\n    train_loss = 0\n    correct_train = 0\n    total_train = 0\n\n    for x, y in tqdm(train_loader, desc=f\"Epoch {epoch+1}/{opt.n_epochs} - Train\"):\n        x, y = x.to(device), y.to(device)\n        optimizer.zero_grad()\n        out = model(x)\n        loss = criterion(out, y)\n        loss.backward()\n        optimizer.step()\n        train_loss += loss.item()\n\n        # Accuracy hesaplama (sınıflandırma varsayımıyla)\n        _, predicted = torch.max(out, 1)\n        _, labels = torch.max(y, 1)  # Eğer y one-hot ise, değilse direkt y olabilir\n        correct_train += (predicted == labels).sum().item()\n        total_train += labels.size(0)\n\n    train_loss /= len(train_loader)\n    train_accuracy = correct_train / total_train\n    train_losses.append(train_loss)\n    train_accuracies.append(train_accuracy)\n\n    model.eval()\n    val_loss = 0\n    correct_val = 0\n    total_val = 0\n\n    with torch.no_grad():\n        for x, y in val_loader:\n            x, y = x.to(device), y.to(device)\n            out = model(x)\n            loss = criterion(out, y)\n            val_loss += loss.item()\n\n            _, predicted = torch.max(out, 1)\n            _, labels = torch.max(y, 1)  # Yine y'nin yapısına göre düzenle\n            correct_val += (predicted == labels).sum().item()\n            total_val += labels.size(0)\n\n    val_loss /= len(val_loader)\n    val_accuracy = correct_val / total_val\n    val_losses.append(val_loss)\n    val_accuracies.append(val_accuracy)\n\n    print(f\"Epoch {epoch+1}/{opt.n_epochs} - Train Loss: {train_loss:.4f} - Val Loss: {val_loss:.4f} - Train Acc: {train_accuracy:.4f} - Val Acc: {val_accuracy:.4f}\")\n\n    # Early Stopping\n    if val_loss < best_val_loss:\n        best_val_loss = val_loss\n        counter = 0\n        torch.save(model.state_dict(), \"best_model.pt\")\n        print(\"Model kaydedildi.\")\n    else:\n        counter += 1\n        print(f\"EarlyStopping counter: {counter} / {patience}\")\n        if counter >= patience:\n            print(\"Early stopping devreye girdi. Eğitim durduruluyor.\")\n            break","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T02:08:11.700003Z","iopub.execute_input":"2025-06-15T02:08:11.700408Z","iopub.status.idle":"2025-06-15T07:52:41.636476Z","shell.execute_reply.started":"2025-06-15T02:08:11.700387Z","shell.execute_reply":"2025-06-15T07:52:41.634907Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Eğitim bittikten sonra grafik çizimi\nepochs = range(1, len(train_losses) + 1)\n\nplt.figure(figsize=(12,5))\n\nplt.subplot(1,2,1)\nplt.plot(epochs, train_losses, 'b-', label='Train Loss')\nplt.plot(epochs, val_losses, 'r-', label='Validation Loss')\nplt.xlabel('Epoch')\nplt.ylabel('Loss')\nplt.title('Loss over Epochs')\nplt.legend()\n\nplt.subplot(1,2,2)\nplt.plot(epochs, train_accuracies, 'b-', label='Train Accuracy')\nplt.plot(epochs, val_accuracies, 'r-', label='Validation Accuracy')\nplt.xlabel('Epoch')\nplt.ylabel('Accuracy')\nplt.title('Accuracy over Epochs')\nplt.legend()\n\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T07:52:41.638271Z","iopub.execute_input":"2025-06-15T07:52:41.638617Z","iopub.status.idle":"2025-06-15T07:52:42.238428Z","shell.execute_reply.started":"2025-06-15T07:52:41.638582Z","shell.execute_reply":"2025-06-15T07:52:42.237312Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# --------------------------\n# 7. Model Kaydet\n# --------------------------\ntorch.save(model.state_dict(), \"best_model.pt\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T07:52:42.239810Z","iopub.execute_input":"2025-06-15T07:52:42.240712Z","iopub.status.idle":"2025-06-15T07:52:42.255083Z","shell.execute_reply.started":"2025-06-15T07:52:42.240674Z","shell.execute_reply":"2025-06-15T07:52:42.253910Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# --------------------------\n# 4. Test Verisini Hazırla ve Normalize Et\n# --------------------------\nTEST_DIR = '/kaggle/working/test/test'\nFNAME = os.path.join(TEST_DIR, 'subj{}_series{}_data.csv')\n\ntrial_lengths = {}\ntest_data = []\n\nfor subj in range(1, 13):\n    for series in [9, 10]:\n        df = pd.read_csv(FNAME.format(subj, series))\n        df = df.select_dtypes(include=[np.number])  # Sadece sayısal sütunları al\n        trial_lengths[f'{subj}_{series}'] = len(df)\n        test_data.append(df.values.T.astype(np.float32))  # (channels=32, T)\n\ntest_data = np.concatenate(test_data, axis=1)  # (32, total_T)\n\n# Burada normalizasyon için ideal olan eğitim verisinden alınan mean/std kullanmaktır\n# Eğer eğitimde yoksa test verisinden hesapla (örnek)\nmean = test_data.mean(axis=1, keepdims=True)\nstd = test_data.std(axis=1, keepdims=True)\ntest_data = (test_data - mean) / (std + 1e-7)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T07:52:42.256122Z","iopub.execute_input":"2025-06-15T07:52:42.256374Z","iopub.status.idle":"2025-06-15T07:52:56.051221Z","shell.execute_reply.started":"2025-06-15T07:52:42.256355Z","shell.execute_reply":"2025-06-15T07:52:56.050159Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Dataset ve DataLoader oluştur\ntest_dataset = EEGDataset(test_data, labels=None, train=False)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T07:52:56.052399Z","iopub.execute_input":"2025-06-15T07:52:56.052749Z","iopub.status.idle":"2025-06-15T07:52:56.057715Z","shell.execute_reply.started":"2025-06-15T07:52:56.052719Z","shell.execute_reply":"2025-06-15T07:52:56.056929Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"class EEGBatchDataset(Dataset):\n    def __init__(self, data, labels=None, train=True):\n        self.data = data\n        self.labels = labels\n        self.train = train\n\n    def __len__(self):\n        return len(self.data)\n\n    def __getitem__(self, idx):\n        x = self.data[idx]  # (channels, window_size)\n        if self.train and self.labels is not None:\n            y = self.labels[idx]\n            return torch.tensor(x, dtype=torch.float32), torch.tensor(y, dtype=torch.float32)\n        else:\n            return torch.tensor(x, dtype=torch.float32)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T07:52:56.058691Z","iopub.execute_input":"2025-06-15T07:52:56.059036Z","iopub.status.idle":"2025-06-15T07:52:56.080030Z","shell.execute_reply.started":"2025-06-15T07:52:56.058995Z","shell.execute_reply":"2025-06-15T07:52:56.078875Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Biz pencereleme yaptığımız için test için de pencereleme yapalım:\n\ndef sliding_window(data, window_size=opt.in_len, step_size=100):\n    windows = []\n    for start in range(0, data.shape[1]-window_size+1, step_size):\n        windows.append(data[:, start:start+window_size])\n    return np.stack(windows)\n\ntest_windows = sliding_window(test_data, window_size=opt.in_len, step_size=100)  # (num_windows, channels, window_size)\n\n# 🔁 Hatalı EEGDataset yerine doğru sınıfı kullan\ntest_dataset = EEGBatchDataset(test_windows, train=False)\ntest_loader = DataLoader(test_dataset, batch_size=opt.batch_size, shuffle=False, num_workers=opt.n_cpu)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T07:52:56.081349Z","iopub.execute_input":"2025-06-15T07:52:56.081681Z","iopub.status.idle":"2025-06-15T07:53:00.768936Z","shell.execute_reply.started":"2025-06-15T07:52:56.081649Z","shell.execute_reply":"2025-06-15T07:53:00.767864Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Modeli yükle\nmodel.load_state_dict(torch.load(\"best_model.pt\", map_location=device))\nmodel.eval()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T07:53:00.769981Z","iopub.execute_input":"2025-06-15T07:53:00.770219Z","iopub.status.idle":"2025-06-15T07:53:00.787256Z","shell.execute_reply.started":"2025-06-15T07:53:00.770200Z","shell.execute_reply":"2025-06-15T07:53:00.786404Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Tahmin yap\ny_pred = []\nwith torch.no_grad():\n    for x in tqdm(test_loader, desc=\"Test Prediction\"):\n        x = x.to(device)\n        out = model(x)\n        y_pred.append(out.cpu().numpy())\n\ny_pred = np.concatenate(y_pred, axis=0)  # (num_samples, 6)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T07:53:00.788205Z","iopub.execute_input":"2025-06-15T07:53:00.788461Z","iopub.status.idle":"2025-06-15T08:00:14.740484Z","shell.execute_reply.started":"2025-06-15T07:53:00.788442Z","shell.execute_reply":"2025-06-15T08:00:14.739342Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Submission için index hazırla\nsubmission_index = []\nfor subj in range(1, 13):\n    for series in [9, 10]:\n        length = trial_lengths[f'{subj}_{series}']\n        for t in range(length):\n            submission_index.append(f'subj{subj}_series{series}_{t}')\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T08:00:14.742572Z","iopub.execute_input":"2025-06-15T08:00:14.742913Z","iopub.status.idle":"2025-06-15T08:00:16.350796Z","shell.execute_reply.started":"2025-06-15T08:00:14.742878Z","shell.execute_reply":"2025-06-15T08:00:16.350068Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Pencere boyutundan dolayı başta eksik tahmin olabilir, padding yap\npad_len = len(submission_index) - len(y_pred)\nif pad_len > 0:\n    y_pred = np.vstack([np.zeros((pad_len, 6)), y_pred])\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T08:00:16.351783Z","iopub.execute_input":"2025-06-15T08:00:16.352104Z","iopub.status.idle":"2025-06-15T08:00:16.632492Z","shell.execute_reply.started":"2025-06-15T08:00:16.352082Z","shell.execute_reply":"2025-06-15T08:00:16.631654Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Etiket isimleri\nlabels = ['HandStart', 'FirstDigitTouch', 'BothStartLoadPhase', 'LiftOff', 'Replace', 'BothReleased']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T08:00:16.633588Z","iopub.execute_input":"2025-06-15T08:00:16.633840Z","iopub.status.idle":"2025-06-15T08:00:16.638815Z","shell.execute_reply.started":"2025-06-15T08:00:16.633820Z","shell.execute_reply":"2025-06-15T08:00:16.637897Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Submission DataFrame oluştur ve kaydet\nsubmission = pd.DataFrame(y_pred, index=submission_index, columns=labels)\nsubmission.to_csv(\"submission.csv\", index_label=\"id\", float_format='%.3f')\nprint(\"submission.csv dosyası kaydedildi.\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-15T08:00:16.639907Z","iopub.execute_input":"2025-06-15T08:00:16.640183Z","iopub.status.idle":"2025-06-15T08:00:45.878742Z","shell.execute_reply.started":"2025-06-15T08:00:16.640166Z","shell.execute_reply":"2025-06-15T08:00:45.877845Z"}},"outputs":[],"execution_count":null}]}