{"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":29653,"databundleVersionId":2420395,"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 torch\nimport torch.nn as nn\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib\nimport pydicom as dicom\nimport cv2\nimport ast\n\nimport warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:40.642408Z","iopub.execute_input":"2026-07-10T17:30:40.642711Z","iopub.status.idle":"2026-07-10T17:30:47.498888Z","shell.execute_reply.started":"2026-07-10T17:30:40.642691Z","shell.execute_reply":"2026-07-10T17:30:47.497980Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"path = '/kaggle/input/rsna-miccai-brain-tumor-radiogenomic-classification/'\nos.listdir(path)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:47.500180Z","iopub.execute_input":"2026-07-10T17:30:47.500545Z","iopub.status.idle":"2026-07-10T17:30:47.507585Z","shell.execute_reply.started":"2026-07-10T17:30:47.500521Z","shell.execute_reply":"2026-07-10T17:30:47.506474Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"path = '/kaggle/input/rsna-miccai-brain-tumor-radiogenomic-classification/'\nos.listdir(path)\ntrain_data = pd.read_csv(path+'train_labels.csv')\nsamp_subm = pd.read_csv(path+'sample_submission.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:47.508323Z","iopub.execute_input":"2026-07-10T17:30:47.508527Z","iopub.status.idle":"2026-07-10T17:30:47.550580Z","shell.execute_reply.started":"2026-07-10T17:30:47.508509Z","shell.execute_reply":"2026-07-10T17:30:47.549926Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print('Samples train:', len(train_data))\nprint('Samples test:', len(samp_subm))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:47.552307Z","iopub.execute_input":"2026-07-10T17:30:47.553026Z","iopub.status.idle":"2026-07-10T17:30:47.557671Z","shell.execute_reply.started":"2026-07-10T17:30:47.553009Z","shell.execute_reply":"2026-07-10T17:30:47.556495Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:47.558795Z","iopub.execute_input":"2026-07-10T17:30:47.559040Z","iopub.status.idle":"2026-07-10T17:30:47.596500Z","shell.execute_reply.started":"2026-07-10T17:30:47.559019Z","shell.execute_reply":"2026-07-10T17:30:47.595681Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"MGMT_value\"].value_counts().head(2).plot(kind = 'pie', autopct='%1.1f%%', figsize=(8, 8)).legend()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:47.597262Z","iopub.execute_input":"2026-07-10T17:30:47.597491Z","iopub.status.idle":"2026-07-10T17:30:48.015554Z","shell.execute_reply.started":"2026-07-10T17:30:47.597474Z","shell.execute_reply":"2026-07-10T17:30:48.014512Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"MGMT_value\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:48.016629Z","iopub.execute_input":"2026-07-10T17:30:48.016836Z","iopub.status.idle":"2026-07-10T17:30:48.024000Z","shell.execute_reply.started":"2026-07-10T17:30:48.016821Z","shell.execute_reply":"2026-07-10T17:30:48.022654Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"samp_subm.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:48.025173Z","iopub.execute_input":"2026-07-10T17:30:48.025483Z","iopub.status.idle":"2026-07-10T17:30:48.051141Z","shell.execute_reply.started":"2026-07-10T17:30:48.025461Z","shell.execute_reply":"2026-07-10T17:30:48.050094Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"folder = str(train_data.loc[0, 'BraTS21ID']).zfill(5)\nfolder","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:48.051855Z","iopub.execute_input":"2026-07-10T17:30:48.052132Z","iopub.status.idle":"2026-07-10T17:30:48.074536Z","shell.execute_reply.started":"2026-07-10T17:30:48.052096Z","shell.execute_reply":"2026-07-10T17:30:48.073555Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"os.listdir(path+'train/'+folder)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:48.077533Z","iopub.execute_input":"2026-07-10T17:30:48.077811Z","iopub.status.idle":"2026-07-10T17:30:48.104071Z","shell.execute_reply.started":"2026-07-10T17:30:48.077791Z","shell.execute_reply":"2026-07-10T17:30:48.102844Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print('Number of FLAIR images:', len(os.listdir(path+'train/'+folder+'/'+'FLAIR')))\nprint('Number of T1w images:', len(os.listdir(path+'train/'+folder+'/'+'T1w')))\nprint('Number of T1wCE images:', len(os.listdir(path+'train/'+folder+'/'+'T1wCE')))\nprint('Number of T2w images:', len(os.listdir(path+'train/'+folder+'/'+'T2w')))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:48.105353Z","iopub.execute_input":"2026-07-10T17:30:48.105739Z","iopub.status.idle":"2026-07-10T17:30:48.168156Z","shell.execute_reply.started":"2026-07-10T17:30:48.105712Z","shell.execute_reply":"2026-07-10T17:30:48.166934Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"path_file = ''.join([path, 'train/', folder, '/', 'FLAIR/'])\nimage = os.listdir(path_file)[0]\ndata_file = dicom.dcmread(path_file+image)\nimg = data_file.pixel_array\nprint('Image shape:', img.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:48.168990Z","iopub.execute_input":"2026-07-10T17:30:48.169203Z","iopub.status.idle":"2026-07-10T17:30:48.185982Z","shell.execute_reply.started":"2026-07-10T17:30:48.169185Z","shell.execute_reply":"2026-07-10T17:30:48.185077Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#Flair Image\ndef plot_examples(row = 0, cat = 'FLAIR'): \n    folder = str(train_data.loc[row, 'BraTS21ID']).zfill(5)\n    path_file = ''.join([path, 'train/', folder, '/', cat, '/'])\n    images = os.listdir(path_file)\n    \n    fig, axs = plt.subplots(1, 5, figsize=(30, 30))\n    fig.subplots_adjust(hspace = .2, wspace=.2)\n    axs = axs.ravel()\n    \n    for num in range(5):\n        data_file = dicom.dcmread(path_file+images[num])\n        img = data_file.pixel_array\n        axs[num].imshow(img, cmap='gray')\n        axs[num].set_title(cat+' '+images[num])\n        axs[num].set_xticklabels([])\n        axs[num].set_yticklabels([])\n        \nrow = 0\nplot_examples(row = row, cat = 'FLAIR')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:48.186985Z","iopub.execute_input":"2026-07-10T17:30:48.187204Z","iopub.status.idle":"2026-07-10T17:30:48.805411Z","shell.execute_reply.started":"2026-07-10T17:30:48.187168Z","shell.execute_reply":"2026-07-10T17:30:48.804445Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#T1w Images\nplot_examples(row = row, cat = 'T1w')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:48.806297Z","iopub.execute_input":"2026-07-10T17:30:48.806513Z","iopub.status.idle":"2026-07-10T17:30:49.377763Z","shell.execute_reply.started":"2026-07-10T17:30:48.806495Z","shell.execute_reply":"2026-07-10T17:30:49.377003Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#T1wCE Images\nplot_examples(row = row, cat = 'T1wCE')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:49.378483Z","iopub.execute_input":"2026-07-10T17:30:49.378730Z","iopub.status.idle":"2026-07-10T17:30:49.947509Z","shell.execute_reply.started":"2026-07-10T17:30:49.378711Z","shell.execute_reply":"2026-07-10T17:30:49.946689Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#T2w Images\nplot_examples(row = row, cat = 'T2w')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:49.948587Z","iopub.execute_input":"2026-07-10T17:30:49.948866Z","iopub.status.idle":"2026-07-10T17:30:50.581123Z","shell.execute_reply.started":"2026-07-10T17:30:49.948846Z","shell.execute_reply":"2026-07-10T17:30:50.580047Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nimport pydicom\nimport tensorflow as tf\nfrom tensorflow.keras import layers, models\nfrom sklearn.model_selection import train_test_split\nimport cv2\nimport matplotlib.pyplot as plt\nfrom sklearn.metrics import classification_report, confusion_matrix, roc_curve, auc\n\n# Path dataset\npath = '/kaggle/input/rsna-miccai-brain-tumor-radiogenomic-classification/'\ntrain_labels = pd.read_csv(path + 'train_labels.csv')\n\n# Konfigurasi\nIMG_SIZE = 128\nBATCH_SIZE = 32\nEPOCHS = 15\nMODALITY = 'FLAIR' \n\n# Fungsi untuk membaca dan memproses gambar DICOM\ndef load_dicom_image(filepath, img_size=IMG_SIZE):\n    dicom = pydicom.dcmread(filepath)\n    img = dicom.pixel_array.astype(float)\n    \n    # Normalisasi\n    img = (img - img.min()) / (img.max() - img.min())\n    \n    # Konversi ke uint8\n    img = (img * 255).astype(np.uint8)\n    \n    # Resize\n    img = cv2.resize(img, (img_size, img_size))\n    \n    # Stack ke 3 channel\n    img = np.stack([img]*3, axis=-1)\n    return img\n\n# Fungsi untuk memuat data pasien\ndef load_patient_data(patient_id, num_slices=16):\n    patient_path = os.path.join(path, 'train', str(patient_id).zfill(5), MODALITY)\n    slices = []\n    \n    if not os.path.exists(patient_path):\n        print(f\"Data tidak ditemukan untuk pasien {patient_id}\")\n        return None\n    \n    # Dapatkan semua file DICOM\n    dicom_files = sorted([f for f in os.listdir(patient_path) if f.endswith('.dcm')])\n    \n    if not dicom_files:\n        print(f\"Tidak ada file DICOM untuk pasien {patient_id}\")\n        return None\n    \n    # Pilih slice secara merata\n    step = max(1, len(dicom_files) // num_slices)\n    selected_files = dicom_files[::step][:num_slices]\n    \n    # Muat slice yang dipilih\n    for filename in selected_files:\n        img_path = os.path.join(patient_path, filename)\n        img = load_dicom_image(img_path)\n        slices.append(img)\n    \n    # Jika tidak cukup slice, duplikat yang terakhir\n    while len(slices) < num_slices:\n        slices.append(slices[-1].copy())  # Gunakan copy untuk menghindari reference yang sama\n    \n    return np.array(slices)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:30:50.582036Z","iopub.execute_input":"2026-07-10T17:30:50.582924Z","iopub.status.idle":"2026-07-10T17:31:08.285120Z","shell.execute_reply.started":"2026-07-10T17:30:50.582900Z","shell.execute_reply":"2026-07-10T17:31:08.284085Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Membuat dataset\nX = []\ny = []\n\nprint(\"Memuat data training...\")\nfor idx, row in train_labels.iterrows():\n    patient_id = row['BraTS21ID']\n    label = row['MGMT_value']\n    \n    patient_data = load_patient_data(patient_id)\n    if patient_data is not None:\n        X.append(patient_data)\n        y.append(label)\n\n# Konversi ke numpy array\nX = np.array(X, dtype=np.float32)\ny = np.array(y, dtype=np.float32)\n\nprint(f\"Total data yang dimuat: {len(X)} sampel\")\nprint(f\"Distribusi kelas: {np.sum(y == 1)} positif, {np.sum(y == 0)} negatif\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:31:08.286027Z","iopub.execute_input":"2026-07-10T17:31:08.286275Z","iopub.status.idle":"2026-07-10T17:32:36.264434Z","shell.execute_reply.started":"2026-07-10T17:31:08.286256Z","shell.execute_reply":"2026-07-10T17:32:36.263743Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Split data: training (60%), validation (20%), test (20%)\nX_train, X_temp, y_train, y_temp = train_test_split(\n    X, y, test_size=0.4, random_state=42, stratify=y\n)\nX_val, X_test, y_val, y_test = train_test_split(\n    X_temp, y_temp, test_size=0.5, random_state=42, stratify=y_temp\n)\n\nprint(\"\\nDistribusi dataset:\")\nprint(f\"Training:   {len(X_train)} sampel\")\nprint(f\"Validation: {len(X_val)} sampel\")\nprint(f\"Test:       {len(X_test)} sampel\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:32:36.265078Z","iopub.execute_input":"2026-07-10T17:32:36.265264Z","iopub.status.idle":"2026-07-10T17:32:36.672477Z","shell.execute_reply.started":"2026-07-10T17:32:36.265250Z","shell.execute_reply":"2026-07-10T17:32:36.671689Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def build_3d_cnn(input_shape, num_classes):\n    model = models.Sequential([\n        # Bloc 1\n        layers.Conv3D(32, (3,3,3), activation='relu', padding='same', input_shape=input_shape),\n        layers.BatchNormalization(),\n        layers.MaxPooling3D((2,2,2)),\n        layers.Dropout(0.2),\n\n        # Bloc 2\n        layers.Conv3D(64, (3,3,3), activation='relu', padding='same'),\n        layers.BatchNormalization(),\n        layers.MaxPooling3D((2,2,2)),\n        layers.Dropout(0.3),\n\n        # Bloc 3\n        layers.Conv3D(128, (3,3,3), activation='relu', padding='same'),\n        layers.BatchNormalization(),\n        layers.MaxPooling3D((2,2,2)),\n        layers.Dropout(0.4),\n\n        layers.GlobalAveragePooling3D(),\n\n        layers.Dense(256, activation='relu'),\n        layers.Dropout(0.4),\n\n        layers.Dense(num_classes, activation='sigmoid')\n    ])\n\n    return model","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:32:36.673254Z","iopub.execute_input":"2026-07-10T17:32:36.673928Z","iopub.status.idle":"2026-07-10T17:32:36.678473Z","shell.execute_reply.started":"2026-07-10T17:32:36.673905Z","shell.execute_reply":"2026-07-10T17:32:36.677890Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Bangun model\ninput_shape = (X_train.shape[1], X_train.shape[2], X_train.shape[3], X_train.shape[4])\nprint(f\"\\nInput shape: {input_shape}\")\nmodel = build_3d_cnn(input_shape, num_classes=1)\n\n# Ringkasan model\nmodel.summary()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:32:36.679140Z","iopub.execute_input":"2026-07-10T17:32:36.679330Z","iopub.status.idle":"2026-07-10T17:32:37.186317Z","shell.execute_reply.started":"2026-07-10T17:32:36.679315Z","shell.execute_reply":"2026-07-10T17:32:37.185513Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Kompilasi model\nmodel.compile(\n    optimizer = tf.keras.optimizers.Adam(learning_rate=0.0001),\n    loss='binary_crossentropy',\n    metrics=['accuracy', tf.keras.metrics.AUC(name='auc')]\n)\n\n# Callback\ncallbacks = [\n    tf.keras.callbacks.EarlyStopping(\n        patience=5, \n        monitor='val_auc', \n        mode='max', \n        restore_best_weights=True,\n        verbose=1\n    ),\n    tf.keras.callbacks.ReduceLROnPlateau(\n        monitor='val_loss', \n        factor=0.2, \n        patience=3, \n        min_lr=1e-6,\n        verbose=1\n    ),\n    tf.keras.callbacks.ModelCheckpoint(\n        filepath='best_model.h5',\n        save_best_only=True,\n        monitor='val_auc',\n        mode='max',\n        verbose=1\n    )\n]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:32:37.187073Z","iopub.execute_input":"2026-07-10T17:32:37.187232Z","iopub.status.idle":"2026-07-10T17:32:37.206236Z","shell.execute_reply.started":"2026-07-10T17:32:37.187219Z","shell.execute_reply":"2026-07-10T17:32:37.205562Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#Training\nprint(\"\\nMemulai training...\")\nhistory = model.fit(\n    X_train, y_train,\n    validation_data=(X_val, y_val),\n    batch_size=16,\n    epochs=30,\n    callbacks=callbacks\n)\n\n# Plot history training\ndef plot_history(history):\n    plt.figure(figsize=(12, 5))\n    \n    # Plot loss\n    plt.subplot(1, 2, 1)\n    plt.plot(history.history['loss'], label='Training Loss')\n    plt.plot(history.history['val_loss'], label='Validation Loss')\n    plt.title('Training and Validation Loss')\n    plt.xlabel('Epoch')\n    plt.ylabel('Loss')\n    plt.legend()\n    \n    # Plot AUC\n    plt.subplot(1, 2, 2)\n    plt.plot(history.history['auc'], label='Training AUC')\n    plt.plot(history.history['val_auc'], label='Validation AUC')\n    plt.title('Training and Validation AUC')\n    plt.xlabel('Epoch')\n    plt.ylabel('AUC')\n    plt.legend()\n    \n    plt.tight_layout()\n    plt.savefig('training_history.png')\n    plt.show()\n\nplot_history(history)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T17:32:37.206940Z","iopub.execute_input":"2026-07-10T17:32:37.207131Z","iopub.status.idle":"2026-07-10T18:06:56.361536Z","shell.execute_reply.started":"2026-07-10T17:32:37.207114Z","shell.execute_reply":"2026-07-10T18:06:56.360750Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Evaluasi pada validation set\nprint(\"\\nEvaluasi pada validation set:\")\nval_loss, val_acc, val_auc = model.evaluate(X_val, y_val)\nprint(f\"Validation Loss: {val_loss:.4f}\")\nprint(f\"Validation Accuracy: {val_acc:.4f}\")\nprint(f\"Validation AUC: {val_auc:.4f}\")\n\n# Evaluasi pada test set\nprint(\"\\nEvaluasi pada test set:\")\ntest_loss, test_acc, test_auc = model.evaluate(X_test, y_test)\nprint(f\"Test Loss: {test_loss:.4f}\")  \nprint(f\"Test Accuracy: {test_acc:.4f}\")  \nprint(f\"Test AUC: {test_auc:.4f}\") ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T18:06:56.362617Z","iopub.execute_input":"2026-07-10T18:06:56.362881Z","iopub.status.idle":"2026-07-10T18:07:22.591979Z","shell.execute_reply.started":"2026-07-10T18:06:56.362859Z","shell.execute_reply":"2026-07-10T18:07:22.591058Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Prediksi pada test set\ny_pred_prob = model.predict(X_test).flatten()\ny_pred = (y_pred_prob > 0.5).astype(int)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T18:07:22.592838Z","iopub.execute_input":"2026-07-10T18:07:22.593142Z","iopub.status.idle":"2026-07-10T18:07:35.916962Z","shell.execute_reply.started":"2026-07-10T18:07:22.593120Z","shell.execute_reply":"2026-07-10T18:07:35.916210Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Classification report\nprint(\"\\nClassification Report:\")\nprint(classification_report(y_test, y_pred))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T18:07:35.917904Z","iopub.execute_input":"2026-07-10T18:07:35.918148Z","iopub.status.idle":"2026-07-10T18:07:35.932168Z","shell.execute_reply.started":"2026-07-10T18:07:35.918130Z","shell.execute_reply":"2026-07-10T18:07:35.931464Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Confusion matrix\nconf_matrix = confusion_matrix(y_test, y_pred)\nprint(\"\\nConfusion Matrix:\")\nprint(conf_matrix)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T18:07:35.933035Z","iopub.execute_input":"2026-07-10T18:07:35.933377Z","iopub.status.idle":"2026-07-10T18:07:35.956614Z","shell.execute_reply.started":"2026-07-10T18:07:35.933339Z","shell.execute_reply":"2026-07-10T18:07:35.955705Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Plot ROC curve\nfpr, tpr, thresholds = roc_curve(y_test, y_pred_prob)\nroc_auc = auc(fpr, tpr)\n\nplt.figure()\nplt.plot(fpr, tpr, color='darkorange', lw=2, label=f'ROC curve (area = {roc_auc:.2f})')\nplt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')\nplt.xlim([0.0, 1.0])\nplt.ylim([0.0, 1.05])\nplt.xlabel('False Positive Rate')\nplt.ylabel('True Positive Rate')\nplt.title('Receiver Operating Characteristic')\nplt.legend(loc=\"lower right\")\nplt.savefig('roc_curve.png')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T18:07:35.959849Z","iopub.execute_input":"2026-07-10T18:07:35.960125Z","iopub.status.idle":"2026-07-10T18:07:36.167446Z","shell.execute_reply.started":"2026-07-10T18:07:35.960070Z","shell.execute_reply":"2026-07-10T18:07:36.166560Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Simpan model akhir\nmodel.save('final_model.h5')\nprint(\"\\nModel akhir disimpan sebagai 'final_model.h5'\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-07-10T18:07:36.168209Z","iopub.execute_input":"2026-07-10T18:07:36.168450Z","iopub.status.idle":"2026-07-10T18:07:36.216118Z","shell.execute_reply.started":"2026-07-10T18:07:36.168427Z","shell.execute_reply":"2026-07-10T18:07:36.214886Z"}},"outputs":[],"execution_count":null}]}