{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":52254,"databundleVersionId":9674523,"sourceType":"competition"},{"sourceId":6211844,"sourceType":"datasetVersion","datasetId":3567114}],"dockerImageVersionId":30699,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# <center>Medical image ...</center>\n\n","metadata":{"papermill":{"duration":0.025483,"end_time":"2022-02-01T10:21:43.84374","exception":false,"start_time":"2022-02-01T10:21:43.818257","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"## To commence this project, the neccesary libraries need to be installed.\n## We would be using the **TensorFlow** framework and the pretrained **EfficientNetB1**\n","metadata":{}},{"cell_type":"code","source":"# Imporitng libraries\nimport pandas as pd\nimport os\nimport random\nimport numpy as np\nimport tensorflow as tf\nimport cv2\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom IPython.display import clear_output\nfrom sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay\nfrom sklearn.model_selection import StratifiedKFold\nfrom tensorflow.keras import backend as K\n\nrandom.seed(42)","metadata":{"id":"fUPKjZaaJHkM","papermill":{"duration":5.021373,"end_time":"2022-02-01T10:21:48.88737","exception":false,"start_time":"2022-02-01T10:21:43.865997","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-11-09T09:34:56.69804Z","iopub.execute_input":"2024-11-09T09:34:56.698457Z","iopub.status.idle":"2024-11-09T09:34:56.704956Z","shell.execute_reply.started":"2024-11-09T09:34:56.698428Z","shell.execute_reply":"2024-11-09T09:34:56.703957Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Loading the training dataset\ntrain_img = \"/kaggle/input/rsna-atd-512x512-png-v2-dataset/train_images\"","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:56.706559Z","iopub.execute_input":"2024-11-09T09:34:56.706882Z","iopub.status.idle":"2024-11-09T09:34:56.718256Z","shell.execute_reply.started":"2024-11-09T09:34:56.706857Z","shell.execute_reply":"2024-11-09T09:34:56.717106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in os.listdir(train_img):\n    for j in os.listdir(os.path.join(train_img,i)):\n        print(len(os.listdir(os.path.join(train_img,i,j))))","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:56.71944Z","iopub.execute_input":"2024-11-09T09:34:56.719792Z","iopub.status.idle":"2024-11-09T09:34:57.033798Z","shell.execute_reply.started":"2024-11-09T09:34:56.71976Z","shell.execute_reply":"2024-11-09T09:34:57.032758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Part A\n## Import and explore the data","metadata":{"papermill":{"duration":0.02193,"end_time":"2022-02-01T10:21:48.93356","exception":false,"start_time":"2022-02-01T10:21:48.91163","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Making a list containing all unique classes in the training set\n\n# Reading the training labels\ntraining_labels = pd.read_csv(\"/kaggle/input/rsna-2023-abdominal-trauma-detection/train_2024.csv\")","metadata":{"id":"PBlH8ae3LbG0","papermill":{"duration":0.069238,"end_time":"2022-02-01T10:21:49.024476","exception":false,"start_time":"2022-02-01T10:21:48.955238","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-11-09T09:34:57.03598Z","iopub.execute_input":"2024-11-09T09:34:57.036264Z","iopub.status.idle":"2024-11-09T09:34:57.047359Z","shell.execute_reply.started":"2024-11-09T09:34:57.036239Z","shell.execute_reply":"2024-11-09T09:34:57.046175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Viewing the dataset in a structured format\ntraining_labels","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.048705Z","iopub.execute_input":"2024-11-09T09:34:57.049134Z","iopub.status.idle":"2024-11-09T09:34:57.068289Z","shell.execute_reply.started":"2024-11-09T09:34:57.049101Z","shell.execute_reply":"2024-11-09T09:34:57.067379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Part B\n## In the next few cells, we chose to explore the dataframe to check for missing values","metadata":{}},{"cell_type":"code","source":"training_labels.columns","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.069429Z","iopub.execute_input":"2024-11-09T09:34:57.069742Z","iopub.status.idle":"2024-11-09T09:34:57.077779Z","shell.execute_reply.started":"2024-11-09T09:34:57.069719Z","shell.execute_reply":"2024-11-09T09:34:57.076872Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['patient_id'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.078938Z","iopub.execute_input":"2024-11-09T09:34:57.079216Z","iopub.status.idle":"2024-11-09T09:34:57.09395Z","shell.execute_reply.started":"2024-11-09T09:34:57.079192Z","shell.execute_reply":"2024-11-09T09:34:57.092916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['bowel_healthy'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.095022Z","iopub.execute_input":"2024-11-09T09:34:57.09531Z","iopub.status.idle":"2024-11-09T09:34:57.107312Z","shell.execute_reply.started":"2024-11-09T09:34:57.09527Z","shell.execute_reply":"2024-11-09T09:34:57.106466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['bowel_injury'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.108414Z","iopub.execute_input":"2024-11-09T09:34:57.10876Z","iopub.status.idle":"2024-11-09T09:34:57.120374Z","shell.execute_reply.started":"2024-11-09T09:34:57.108729Z","shell.execute_reply":"2024-11-09T09:34:57.119446Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['extravasation_healthy'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.123756Z","iopub.execute_input":"2024-11-09T09:34:57.124012Z","iopub.status.idle":"2024-11-09T09:34:57.134829Z","shell.execute_reply.started":"2024-11-09T09:34:57.12399Z","shell.execute_reply":"2024-11-09T09:34:57.133895Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['extravasation_injury'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.135991Z","iopub.execute_input":"2024-11-09T09:34:57.136329Z","iopub.status.idle":"2024-11-09T09:34:57.148366Z","shell.execute_reply.started":"2024-11-09T09:34:57.136297Z","shell.execute_reply":"2024-11-09T09:34:57.147402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['kidney_healthy'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.149353Z","iopub.execute_input":"2024-11-09T09:34:57.14963Z","iopub.status.idle":"2024-11-09T09:34:57.158905Z","shell.execute_reply.started":"2024-11-09T09:34:57.149582Z","shell.execute_reply":"2024-11-09T09:34:57.158125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['kidney_low'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.159916Z","iopub.execute_input":"2024-11-09T09:34:57.160168Z","iopub.status.idle":"2024-11-09T09:34:57.16978Z","shell.execute_reply.started":"2024-11-09T09:34:57.160146Z","shell.execute_reply":"2024-11-09T09:34:57.168912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['kidney_high'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.170975Z","iopub.execute_input":"2024-11-09T09:34:57.171285Z","iopub.status.idle":"2024-11-09T09:34:57.182891Z","shell.execute_reply.started":"2024-11-09T09:34:57.17126Z","shell.execute_reply":"2024-11-09T09:34:57.181836Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['liver_healthy'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.184004Z","iopub.execute_input":"2024-11-09T09:34:57.184347Z","iopub.status.idle":"2024-11-09T09:34:57.19444Z","shell.execute_reply.started":"2024-11-09T09:34:57.184308Z","shell.execute_reply":"2024-11-09T09:34:57.193494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['liver_low'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.195604Z","iopub.execute_input":"2024-11-09T09:34:57.195904Z","iopub.status.idle":"2024-11-09T09:34:57.206575Z","shell.execute_reply.started":"2024-11-09T09:34:57.195879Z","shell.execute_reply":"2024-11-09T09:34:57.20567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['liver_high'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.207823Z","iopub.execute_input":"2024-11-09T09:34:57.208083Z","iopub.status.idle":"2024-11-09T09:34:57.219063Z","shell.execute_reply.started":"2024-11-09T09:34:57.208061Z","shell.execute_reply":"2024-11-09T09:34:57.218094Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['spleen_healthy'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.220275Z","iopub.execute_input":"2024-11-09T09:34:57.220647Z","iopub.status.idle":"2024-11-09T09:34:57.231281Z","shell.execute_reply.started":"2024-11-09T09:34:57.220596Z","shell.execute_reply":"2024-11-09T09:34:57.230378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['spleen_low'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.232637Z","iopub.execute_input":"2024-11-09T09:34:57.232945Z","iopub.status.idle":"2024-11-09T09:34:57.244444Z","shell.execute_reply.started":"2024-11-09T09:34:57.23292Z","shell.execute_reply":"2024-11-09T09:34:57.243691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['spleen_high'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.245553Z","iopub.execute_input":"2024-11-09T09:34:57.245897Z","iopub.status.idle":"2024-11-09T09:34:57.259064Z","shell.execute_reply.started":"2024-11-09T09:34:57.245867Z","shell.execute_reply":"2024-11-09T09:34:57.25827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels['any_injury'].isna().value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.260087Z","iopub.execute_input":"2024-11-09T09:34:57.260368Z","iopub.status.idle":"2024-11-09T09:34:57.270406Z","shell.execute_reply.started":"2024-11-09T09:34:57.260344Z","shell.execute_reply":"2024-11-09T09:34:57.269599Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class Metrics(tf.keras.metrics.Metric):\n    def __init__(self, name='metrics', **kwargs):\n        super(Metrics, self).__init__(name=name, **kwargs)\n        self.precision = tf.keras.metrics.Precision()\n        self.recall = tf.keras.metrics.Recall()\n\n    def update_state(self, y_true, y_pred, sample_weight=None):\n        self.precision.update_state(y_true, y_pred, sample_weight)\n        self.recall.update_state(y_true, y_pred, sample_weight)\n\n    def result(self):\n        return {\n            \"precision\": self.precision.result(),\n            \"recall\": self.recall.result(),\n            \"f1_score\": 2 * ((self.precision.result() * self.recall.result()) / (self.precision.result() + self.recall.result() + K.epsilon()))\n        }\n\n    def reset_states(self):\n        self.precision.reset_states()\n        self.recall.reset_states()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.271425Z","iopub.execute_input":"2024-11-09T09:34:57.271801Z","iopub.status.idle":"2024-11-09T09:34:57.285189Z","shell.execute_reply.started":"2024-11-09T09:34:57.271766Z","shell.execute_reply":"2024-11-09T09:34:57.28437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"****LR********","metadata":{}},{"cell_type":"code","source":"def create_model(decay_steps=10, warmup_steps=10):\n    base_model = tf.keras.applications.ResNet50(\n        weights=\"imagenet\", \n        include_top=False, \n        input_shape=(512, 512, 3)\n    )\n\n    x = base_model.output\n    x = tf.keras.layers.GlobalAveragePooling2D()(x)\n    x = tf.keras.layers.Dropout(0.2)(x)\n    \n    x_bowel = tf.keras.layers.Dense(32, activation='silu')(x)\n    x_extra = tf.keras.layers.Dense(32, activation='silu')(x)\n    x_liver = tf.keras.layers.Dense(32, activation='silu')(x)\n    x_kidney = tf.keras.layers.Dense(32, activation='silu')(x)\n    x_spleen = tf.keras.layers.Dense(32, activation='silu')(x)\n\n    # Define heads\n    out_bowel = tf.keras.layers.Dense(1, activation='sigmoid', name='bowel')(x_bowel)\n    out_extra = tf.keras.layers.Dense(1, activation='sigmoid', name='extra')(x_extra)\n    out_liver = tf.keras.layers.Dense(3, activation='softmax', name='liver')(x_liver)\n    out_kidney = tf.keras.layers.Dense(3, activation='softmax', name='kidney')(x_kidney)\n    out_spleen = tf.keras.layers.Dense(3, activation='softmax', name='spleen')(x_spleen)\n\n    model = tf.keras.Model(inputs=base_model.input, outputs=[out_bowel, out_extra, out_liver, out_kidney, out_spleen])\n\n    # Cosine Decay\n    cosine_decay = tf.keras.optimizers.schedules.CosineDecay(\n        initial_learning_rate=1e-3,\n        decay_steps=decay_steps,\n        alpha=0.0\n    )\n\n    # Compile the model\n    optimizer = tf.keras.optimizers.Adam(learning_rate=1e-3) \n    loss = [\n        tf.keras.losses.BinaryCrossentropy(),\n        tf.keras.losses.BinaryCrossentropy(),\n        tf.keras.losses.CategoricalCrossentropy(),\n        tf.keras.losses.CategoricalCrossentropy(),\n        tf.keras.losses.CategoricalCrossentropy()\n    ]\n    \n    metrics = [\n    [tf.keras.metrics.BinaryAccuracy(name=\"bowel_binary_accuracy\"), Metrics(name=\"bowel_metrics\")],\n    [tf.keras.metrics.BinaryAccuracy(name=\"extra_binary_accuracy\"), Metrics(name=\"extra_metrics\")],\n    [tf.keras.metrics.CategoricalAccuracy(name=\"liver_cat_accuracy\"), Metrics(name=\"liver_metrics\")],\n    [tf.keras.metrics.CategoricalAccuracy(name=\"kidney_cat_accuracy\"), Metrics(name=\"kidney_metrics\")],\n    [tf.keras.metrics.CategoricalAccuracy(name=\"spleen_cat_accuracy\"), Metrics(name=\"spleen_metrics\")],\n    ]\n    \n    print(\"[INFO] Compiling the model...\")\n    model.compile(\n        optimizer=optimizer,\n        loss=loss,\n        metrics=metrics\n    )\n    \n    return model","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.286576Z","iopub.execute_input":"2024-11-09T09:34:57.286909Z","iopub.status.idle":"2024-11-09T09:34:57.301532Z","shell.execute_reply.started":"2024-11-09T09:34:57.286866Z","shell.execute_reply":"2024-11-09T09:34:57.300576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**K-FOLD**","metadata":{}},{"cell_type":"code","source":"# In ra một số giá trị của training_labels để kiểm tra\nprint(training_labels.head())\nprint(training_labels.index)\n\n# Augmenting and loading data\ndatagen = tf.keras.preprocessing.image.ImageDataGenerator(\n    rotation_range=10,\n    width_shift_range=0.5,\n    height_shift_range=0.5,\n    shear_range=0,\n    zoom_range=0.1,\n    horizontal_flip=True,\n    fill_mode='nearest'\n)\n\ntrain_img_paths = [os.path.join(train_img, folder) for folder in os.listdir(train_img)]\nimages = []\nlabels = []\n\nfor path in train_img_paths:\n    folder = os.listdir(path)[0]  # Lấy tên folder của bệnh nhân\n    file = os.listdir(os.path.join(path, folder))[0]  # Lấy file hình ảnh đầu tiên trong folder\n    image = cv2.imread(os.path.join(path, folder, file), cv2.IMREAD_COLOR)  # Đọc hình ảnh\n    \n    # Kiểm tra xem folder ID có tồn tại trong training_labels không\n    try:\n        label = np.asarray(training_labels.loc[int(folder)])  # Lấy nhãn từ DataFrame\n    except KeyError:\n        continue  \n    images.append(image)  # Thêm hình ảnh vào danh sách\n    labels.append(label)  # Thêm nhãn vào danh sách\n\nimages = np.asarray(images)  # Chuyển danh sách hình ảnh thành mảng NumPy\nlabels = np.asarray(labels)  # Chuyển danh sách nhãn thành mảng NumPy\n\n\n\n# K-fold cross-validation setup\nkfold = StratifiedKFold(n_splits=4, shuffle=True, random_state=42)\noutput_names = [\"bowel\", \"extra\", \"liver\", \"kidney\", \"spleen\"]\n\nfor fold, (train_idx, val_idx) in enumerate(kfold.split(images, np.argmax(labels, axis=1))):\n    print(f\"\\nTraining Fold {fold + 1}...\")\n    \n    X_train, X_val = images[train_idx], images[val_idx]\n    y_train, y_val = labels[train_idx], labels[val_idx]\n    \n    # Continue with model training...\n\n","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:57.302593Z","iopub.execute_input":"2024-11-09T09:34:57.302862Z","iopub.status.idle":"2024-11-09T09:34:58.487421Z","shell.execute_reply.started":"2024-11-09T09:34:57.30284Z","shell.execute_reply":"2024-11-09T09:34:58.486376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Callbacks\nearly_stopping = tf.keras.callbacks.EarlyStopping(patience=5, restore_best_weights=True)\nreduce_lr = tf.keras.callbacks.ReduceLROnPlateau(factor=0.1, patience=2)\n\nmodel_checkpoint = tf.keras.callbacks.ModelCheckpoint('best_model.keras', save_best_only=True)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:58.488708Z","iopub.execute_input":"2024-11-09T09:34:58.488996Z","iopub.status.idle":"2024-11-09T09:34:58.494838Z","shell.execute_reply.started":"2024-11-09T09:34:58.488971Z","shell.execute_reply":"2024-11-09T09:34:58.493667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = create_model()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:58.496095Z","iopub.execute_input":"2024-11-09T09:34:58.496438Z","iopub.status.idle":"2024-11-09T09:34:59.718858Z","shell.execute_reply.started":"2024-11-09T09:34:58.496405Z","shell.execute_reply":"2024-11-09T09:34:59.7178Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.summary()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:59.719935Z","iopub.execute_input":"2024-11-09T09:34:59.720215Z","iopub.status.idle":"2024-11-09T09:34:59.959637Z","shell.execute_reply.started":"2024-11-09T09:34:59.720191Z","shell.execute_reply":"2024-11-09T09:34:59.958812Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf.keras.utils.plot_model(\n    model,\n    to_file='model.png'\n)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:34:59.965449Z","iopub.execute_input":"2024-11-09T09:34:59.965756Z","iopub.status.idle":"2024-11-09T09:35:02.797255Z","shell.execute_reply.started":"2024-11-09T09:34:59.965731Z","shell.execute_reply":"2024-11-09T09:35:02.79627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_labels = training_labels.set_index('patient_id')\ntraining_labels.head(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:02.798402Z","iopub.execute_input":"2024-11-09T09:35:02.798718Z","iopub.status.idle":"2024-11-09T09:35:02.815034Z","shell.execute_reply.started":"2024-11-09T09:35:02.798694Z","shell.execute_reply":"2024-11-09T09:35:02.814137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Part C","metadata":{}},{"cell_type":"code","source":"#Using histogram to get the distribution of the labels and to check if there are outliers and wrong labels\ntraining_labels.hist(figsize=(20,12),bins=2)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:02.816284Z","iopub.execute_input":"2024-11-09T09:35:02.816632Z","iopub.status.idle":"2024-11-09T09:35:05.073624Z","shell.execute_reply.started":"2024-11-09T09:35:02.81659Z","shell.execute_reply":"2024-11-09T09:35:05.072647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images = []\nlabels = []\nfor i in sorted(os.listdir(train_img)):\n    folder = os.listdir(os.path.join(train_img,i))[0]\n    file = os.listdir(os.path.join(train_img,i,folder))[0]\n    images.append(cv2.imread(os.path.join(train_img,i,folder,file), cv2.IMREAD_COLOR ))\n    labels.append(np.asarray(training_labels.loc[int(i)]))\nimages = np.asarray(images)\nlabels = np.asarray(labels)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:05.074846Z","iopub.execute_input":"2024-11-09T09:35:05.07513Z","iopub.status.idle":"2024-11-09T09:35:06.395624Z","shell.execute_reply.started":"2024-11-09T09:35:05.075104Z","shell.execute_reply":"2024-11-09T09:35:06.394826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(images.shape)\nprint(labels.shape)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:06.397032Z","iopub.execute_input":"2024-11-09T09:35:06.397323Z","iopub.status.idle":"2024-11-09T09:35:06.401498Z","shell.execute_reply.started":"2024-11-09T09:35:06.397298Z","shell.execute_reply":"2024-11-09T09:35:06.400511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Example of images","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(30,12))\nfor i in range(20):\n    plt.subplot(4,5,i+1)\n    plt.imshow(images[i])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:06.402701Z","iopub.execute_input":"2024-11-09T09:35:06.403026Z","iopub.status.idle":"2024-11-09T09:35:09.552943Z","shell.execute_reply.started":"2024-11-09T09:35:06.402996Z","shell.execute_reply":"2024-11-09T09:35:09.552123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**BATH SIZE**","metadata":{}},{"cell_type":"code","source":"# Augumenting the training dataset\n# Create an instance of ImageDataGenerator\ndatagen = tf.keras.preprocessing.image.ImageDataGenerator(\n    rotation_range=10,   # Randomly rotate images by up to 20 degrees\n    width_shift_range=0.5,   # Randomly shift images horizontally by up to 5% of the width\n    height_shift_range=0.5,  # Randomly shift images vertically by up to 5% of the height\n    shear_range=0,   # Shear transformations\n    zoom_range=0.1,    # Randomly zoom in on images\n    horizontal_flip=True,   # Randomly flip images horizontally\n    fill_mode='nearest'     # How to fill in newly created pixels after rotation/shifts\n)\n\n# Fit the data generator on your training data\ndatagen.fit(images)\n\n# Generate augmented data\naugmented_data = datagen.flow(images, labels, batch_size=8)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:09.55424Z","iopub.execute_input":"2024-11-09T09:35:09.554658Z","iopub.status.idle":"2024-11-09T09:35:10.203498Z","shell.execute_reply.started":"2024-11-09T09:35:09.554631Z","shell.execute_reply":"2024-11-09T09:35:10.202667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Splittig the training dataset into training set and validation set\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:10.20454Z","iopub.execute_input":"2024-11-09T09:35:10.204818Z","iopub.status.idle":"2024-11-09T09:35:10.209071Z","shell.execute_reply.started":"2024-11-09T09:35:10.204795Z","shell.execute_reply":"2024-11-09T09:35:10.208081Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_val, y_train, y_val = train_test_split(images, labels, test_size=0.25)\n\n#Printing the shapes of the split datasets\nprint(\"Shape of Training Images:\", X_train.shape)\nprint(\"Shape of Training Labels:\", y_train.shape)\nprint(\"Shape of Validation Images:\", X_val.shape)\nprint(\"Shape of Validation Labels:\", y_val.shape)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:10.210246Z","iopub.execute_input":"2024-11-09T09:35:10.210655Z","iopub.status.idle":"2024-11-09T09:35:10.281477Z","shell.execute_reply.started":"2024-11-09T09:35:10.210605Z","shell.execute_reply":"2024-11-09T09:35:10.280508Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Convert augmented data to an array\naugmented_images, augmented_labels = next(augmented_data)\n\n# Print the shapes of the augmented datasets\nprint(\"Shape of Augmented Images:\", augmented_images.shape)\nprint(\"Shape of Augmented Labels:\", augmented_labels.shape)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:10.282596Z","iopub.execute_input":"2024-11-09T09:35:10.282905Z","iopub.status.idle":"2024-11-09T09:35:10.69721Z","shell.execute_reply.started":"2024-11-09T09:35:10.28288Z","shell.execute_reply":"2024-11-09T09:35:10.696251Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(40,20))\nfor i in range(5):\n    plt.subplot(1,5,i+1)\n    plt.imshow(augmented_images[i])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:10.698355Z","iopub.execute_input":"2024-11-09T09:35:10.698678Z","iopub.status.idle":"2024-11-09T09:35:11.803564Z","shell.execute_reply.started":"2024-11-09T09:35:10.698647Z","shell.execute_reply":"2024-11-09T09:35:11.802657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.DataFrame(augmented_labels)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:11.804757Z","iopub.execute_input":"2024-11-09T09:35:11.805068Z","iopub.status.idle":"2024-11-09T09:35:11.818861Z","shell.execute_reply.started":"2024-11-09T09:35:11.805043Z","shell.execute_reply":"2024-11-09T09:35:11.817951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Part D\n## Training the model with the training dataset","metadata":{}},{"cell_type":"code","source":"pd.DataFrame(y_train)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:11.820153Z","iopub.execute_input":"2024-11-09T09:35:11.82051Z","iopub.status.idle":"2024-11-09T09:35:11.838022Z","shell.execute_reply.started":"2024-11-09T09:35:11.820476Z","shell.execute_reply":"2024-11-09T09:35:11.837047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.DataFrame(y_val)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:11.839055Z","iopub.execute_input":"2024-11-09T09:35:11.839312Z","iopub.status.idle":"2024-11-09T09:35:11.857361Z","shell.execute_reply.started":"2024-11-09T09:35:11.83929Z","shell.execute_reply":"2024-11-09T09:35:11.856476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bowel_labels = labels[:,2]\nextravasation_labels = labels[:,4]\nkidney_labels = labels[:,4:7]\nliver_labels = labels[:,7:10]\nspleen_labels = labels[:,10:13]\nany_labels = labels[:,-1]","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:11.85837Z","iopub.execute_input":"2024-11-09T09:35:11.858605Z","iopub.status.idle":"2024-11-09T09:35:11.865393Z","shell.execute_reply.started":"2024-11-09T09:35:11.858584Z","shell.execute_reply":"2024-11-09T09:35:11.864568Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bowel_val = y_val[:,2]\nextravasation_val = y_val[:,4]\nkidney_val = y_val[:,4:7]\nliver_val = y_val[:,7:10]\nspleen_val = y_val[:,10:13]\nany_val = y_val[:,-1]","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:11.866631Z","iopub.execute_input":"2024-11-09T09:35:11.866983Z","iopub.status.idle":"2024-11-09T09:35:11.874557Z","shell.execute_reply.started":"2024-11-09T09:35:11.866951Z","shell.execute_reply":"2024-11-09T09:35:11.873567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bowel_train = y_train[:,2]\nextravasation_train = y_train[:,4]\nkidney_train = y_train[:,4:7]\nliver_train = y_train[:,7:10]\nspleen_train = y_train[:,10:13]\nany_train = y_train[:,-1]","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:11.875791Z","iopub.execute_input":"2024-11-09T09:35:11.87657Z","iopub.status.idle":"2024-11-09T09:35:11.883561Z","shell.execute_reply.started":"2024-11-09T09:35:11.876534Z","shell.execute_reply":"2024-11-09T09:35:11.882718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bowel_test = augmented_labels[:,2]\nextravasation_test = augmented_labels[:,4]\nkidney_test = augmented_labels[:,4:7]\nliver_test = augmented_labels[:,7:10]\nspleen_test = augmented_labels[:,10:13]\nany_test = augmented_labels[:,-1]","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:11.884732Z","iopub.execute_input":"2024-11-09T09:35:11.885856Z","iopub.status.idle":"2024-11-09T09:35:11.894465Z","shell.execute_reply.started":"2024-11-09T09:35:11.885829Z","shell.execute_reply":"2024-11-09T09:35:11.893538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**BATH SIZE**","metadata":{}},{"cell_type":"code","source":"batch_size = 8\n# If using tf.data.Dataset for example:\ntrain_data = tf.data.Dataset.from_tensor_slices((X_train, y_train)).batch(batch_size)\nval_data = tf.data.Dataset.from_tensor_slices((X_val, y_val)).batch(batch_size)\n\n# Or, if using ImageDataGenerator:\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\n\n# Set up your data generators\ntrain_datagen = ImageDataGenerator(rescale=1.0/255.0)\nval_datagen = ImageDataGenerator(rescale=1.0/255.0)\n\ntrain_data = train_datagen.flow(X_train, y_train, batch_size=batch_size)\nval_data = val_datagen.flow(X_val, y_val, batch_size=batch_size)\n","metadata":{"execution":{"iopub.status.busy":"2024-11-09T09:35:11.895538Z","iopub.execute_input":"2024-11-09T09:35:11.895855Z","iopub.status.idle":"2024-11-09T09:35:12.537Z","shell.execute_reply.started":"2024-11-09T09:35:11.895832Z","shell.execute_reply":"2024-11-09T09:35:12.536014Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"batch_size = 8\nnum_epoch = 200\nhistory = model.fit(x = X_train,\n                    y =[bowel_train,extravasation_train,kidney_train,liver_train,spleen_train],\n                    validation_data = (X_val, [bowel_val, extravasation_val, kidney_val, liver_val, spleen_val]),\n                    batch_size=batch_size, \n                    epochs = num_epoch, \n                    verbose = 1,\n                    callbacks=[reduce_lr, model_checkpoint]\n                   )","metadata":{"papermill":{"duration":1176.379334,"end_time":"2022-02-01T14:07:30.902597","exception":false,"start_time":"2022-02-01T13:47:54.523263","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-11-09T09:35:12.538161Z","iopub.execute_input":"2024-11-09T09:35:12.53847Z","iopub.status.idle":"2024-11-09T10:05:33.029143Z","shell.execute_reply.started":"2024-11-09T09:35:12.538444Z","shell.execute_reply":"2024-11-09T10:05:33.028292Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history.history.keys()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:33.030684Z","iopub.execute_input":"2024-11-09T10:05:33.030971Z","iopub.status.idle":"2024-11-09T10:05:33.036859Z","shell.execute_reply.started":"2024-11-09T10:05:33.030946Z","shell.execute_reply":"2024-11-09T10:05:33.03597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_acc = ['val_bowel_bowel_binary_accuracy', 'val_extra_extra_binary_accuracy', 'val_liver_liver_cat_accuracy', 'val_kidney_kidney_cat_accuracy', 'val_spleen_spleen_cat_accuracy']","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:33.037948Z","iopub.execute_input":"2024-11-09T10:05:33.038207Z","iopub.status.idle":"2024-11-09T10:05:33.053229Z","shell.execute_reply.started":"2024-11-09T10:05:33.038184Z","shell.execute_reply":"2024-11-09T10:05:33.052426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Khởi tạo biến lưu tổng của tất cả giá trị accuracy và F1 score\ntotal_accuracy_sum = 0\nf1_score_sum = 0\nnum_epoch = len(history.history['f1_score'])  # Xác định số epoch từ dữ liệu hiện có\n\n# Duyệt qua từng epoch để cộng dồn giá trị\nfor epoch in range(num_epoch):\n    # Danh sách lưu trữ các giá trị accuracy có sẵn cho epoch hiện tại\n    accuracies = []\n    \n    # Kiểm tra từng loại accuracy để đảm bảo tồn tại trước khi thêm vào\n    if 'val_bowel_bowel_binary_accuracy' in history.history:\n        accuracies.append(history.history['val_bowel_bowel_binary_accuracy'][epoch])\n    if 'val_extra_extra_binary_accuracy' in history.history:\n        accuracies.append(history.history['val_extra_extra_binary_accuracy'][epoch])\n    if 'val_kidney_kidney_cat_accuracy' in history.history:\n        accuracies.append(history.history['val_kidney_kidney_cat_accuracy'][epoch])\n    if 'val_liver_liver_cat_accuracy' in history.history:\n        accuracies.append(history.history['val_liver_liver_cat_accuracy'][epoch])\n    if 'val_spleen_spleen_cat_accuracy' in history.history:\n        accuracies.append(history.history['val_spleen_spleen_cat_accuracy'][epoch])\n\n    # Tính accuracy trung bình cho epoch này nếu có ít nhất một giá trị\n    if accuracies:\n        total_accuracy = np.mean(accuracies)\n        total_accuracy_sum += total_accuracy\n\n    # Tính F1 trung bình cho mỗi epoch, kiểm tra sự tồn tại của các giá trị tương ứng\n    f1_values = []\n    if 'f1_score' in history.history:\n        f1_values.append(history.history['f1_score'][epoch])\n    if 'bowel_bowel_binary_accuracy' in history.history:\n        f1_values.append(history.history['bowel_bowel_binary_accuracy'][epoch])\n    if 'extra_extra_binary_accuracy' in history.history:\n        f1_values.append(history.history['extra_extra_binary_accuracy'][epoch])\n    if 'kidney_kidney_cat_accuracy' in history.history:\n        f1_values.append(history.history['kidney_kidney_cat_accuracy'][epoch])\n    if 'liver_liver_cat_accuracy' in history.history:\n        f1_values.append(history.history['liver_liver_cat_accuracy'][epoch])\n    if 'spleen_spleen_cat_accuracy' in history.history:\n        f1_values.append(history.history['spleen_spleen_cat_accuracy'][epoch])\n\n    if f1_values:\n        f1_avg = np.mean(f1_values)\n        f1_score_sum += f1_avg\n\n# Tính trung bình tổng của các giá trị accuracy và F1 score\naverage_total_accuracy = total_accuracy_sum / num_epoch\naverage_f1_score = f1_score_sum / num_epoch\n\n# In ra kết quả cuối cùng\nprint(\"\\n=== Summary ===\")\nprint(f\"Overall average Total Accuracy: {average_total_accuracy:.4f}\")\nprint(f\"Overall average F1 Score: {average_f1_score:.4f}\")\n","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:33.054448Z","iopub.execute_input":"2024-11-09T10:05:33.054738Z","iopub.status.idle":"2024-11-09T10:05:33.076557Z","shell.execute_reply.started":"2024-11-09T10:05:33.054715Z","shell.execute_reply":"2024-11-09T10:05:33.075663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i,j in enumerate(val_acc):\n    print(j, np.asarray(history.history[val_acc[i]])[-1].round(2))\n#np.asarray(history.history['val_bowel_bowel_binary_accuracy'])[-1].round(2)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:33.07763Z","iopub.execute_input":"2024-11-09T10:05:33.077981Z","iopub.status.idle":"2024-11-09T10:05:33.094391Z","shell.execute_reply.started":"2024-11-09T10:05:33.077958Z","shell.execute_reply":"2024-11-09T10:05:33.093662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in history.history.keys():\n    if i.endswith(\"accuracy\") and not i ==\"val_accuracy\":\n        plt.plot(history.history[i], label=i)\nplt.xlabel(\"Epochs\")\nplt.ylabel(\"Loss\")\nplt.legend(loc=(1.05,0.0))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:33.095345Z","iopub.execute_input":"2024-11-09T10:05:33.095638Z","iopub.status.idle":"2024-11-09T10:05:33.477701Z","shell.execute_reply.started":"2024-11-09T10:05:33.095576Z","shell.execute_reply":"2024-11-09T10:05:33.476839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(history.history[\"val_loss\"], label=\"val_loss\")\nplt.plot(history.history[\"loss\"], label=\"loss\")\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:33.478927Z","iopub.execute_input":"2024-11-09T10:05:33.479289Z","iopub.status.idle":"2024-11-09T10:05:33.694099Z","shell.execute_reply.started":"2024-11-09T10:05:33.479255Z","shell.execute_reply":"2024-11-09T10:05:33.69313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Testing the model using the Augmented data as test data","metadata":{}},{"cell_type":"code","source":"test_results = model.evaluate(\n    augmented_images, [bowel_test, extravasation_test, kidney_test, liver_test, spleen_test]\n) \n\n# Print the structure of test_results\nprint(\"Test Results Structure:\")\nprint(test_results)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:33.695234Z","iopub.execute_input":"2024-11-09T10:05:33.695539Z","iopub.status.idle":"2024-11-09T10:05:40.191626Z","shell.execute_reply.started":"2024-11-09T10:05:33.695514Z","shell.execute_reply":"2024-11-09T10:05:40.190756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"output_names = [\"bowel\", \"extra\", \"liver\", \"kidney\", \"spleen\"]","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:40.193011Z","iopub.execute_input":"2024-11-09T10:05:40.193301Z","iopub.status.idle":"2024-11-09T10:05:40.197583Z","shell.execute_reply.started":"2024-11-09T10:05:40.193276Z","shell.execute_reply":"2024-11-09T10:05:40.196775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_prob = model.predict(augmented_images)","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:40.19882Z","iopub.execute_input":"2024-11-09T10:05:40.199076Z","iopub.status.idle":"2024-11-09T10:05:44.275267Z","shell.execute_reply.started":"2024-11-09T10:05:40.199054Z","shell.execute_reply":"2024-11-09T10:05:44.274364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Model Output Names:\", model.output_names)  # Check names in model\nprint(\"y_pred_prob:\", y_pred_prob)\nprint(len(y_pred_prob))  # Print predictions and their shape","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:44.277781Z","iopub.execute_input":"2024-11-09T10:05:44.278075Z","iopub.status.idle":"2024-11-09T10:05:44.285725Z","shell.execute_reply.started":"2024-11-09T10:05:44.278049Z","shell.execute_reply":"2024-11-09T10:05:44.284811Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_true_dict = {\n    \"bowel\": bowel_test, \n    \"extra\": extravasation_test,\n    \"liver\": liver_test,\n    \"kidney\": kidney_test,\n    \"spleen\": spleen_test,\n}\n\n\n# Generate and plot confusion matrices for each output\nfor i, output_name in enumerate(output_names):\n    y_true = y_true_dict[output_name]\n    num_classes = 1 if i < 2 else 3  # Binary: 1 class, Multiclass: 3 classes\n    \n    # Ensure y_pred_prob is an array or similar structure\n    if not isinstance(y_pred_prob, (np.ndarray, list, tuple)):\n        y_pred_prob = np.array([y_pred_prob])\n        \n    # If predictions are a tuple of 5 elements\n    if len(y_pred_prob) == 5:\n        # Select the relevant element of the tuple based on the output name\n        y_pred_prob = y_pred_prob[i]\n        \n    # Make sure the predictions are 2D arrays with samples in the first dimension\n    if y_pred_prob.ndim == 1:\n        y_pred_prob = y_pred_prob.reshape(-1, 1)  # Reshape to 2D if necessary\n    \n    if num_classes == 1:\n        # Binary case (but with an extra dimension)\n        y_pred = (y_pred_prob > 0.5).astype(int).flatten()\n        labels = [\"Negative\", \"Positive\"]\n    else:\n        # Multiclass case \n        y_pred = np.argmax(y_pred_prob, axis=1)\n        labels = [f\"Class {i}\" for i in range(y_pred_prob.shape[1])]  \n\n    # Ensure lengths match before calculating the confusion matrix\n    min_len = min(len(y_true), len(y_pred))\n    y_true = y_true[:min_len]\n    y_pred = y_pred[:min_len]\n\n\n    # Ensure both y_true and y_pred are interpreted as multiclass if y_true.ndim > 1:\n    if y_true.ndim > 1:\n        y_true = np.argmax(y_true, axis=1)\n    if y_pred.ndim > 1:\n        y_pred = np.argmax(y_pred, axis=1)\n\n    cm = confusion_matrix(y_true, y_pred)\n    disp = ConfusionMatrixDisplay(confusion_matrix=cm)\n    disp.plot(cmap=plt.cm.Blues)\n\n    # Update ticks and labels directly on the Axes object\n    ax = disp.ax_ \n    ticks = np.arange(len(labels))\n    ax.set_xticks(ticks)\n    ax.set_yticks(ticks)\n    ax.set_xticklabels(labels)\n    ax.set_yticklabels(labels)\n    \n    plt.title(f\"Confusion Matrix - {output_name}\")\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-09T10:05:44.287033Z","iopub.execute_input":"2024-11-09T10:05:44.287304Z","iopub.status.idle":"2024-11-09T10:05:45.540294Z","shell.execute_reply.started":"2024-11-09T10:05:44.287281Z","shell.execute_reply":"2024-11-09T10:05:45.539277Z"},"trusted":true},"execution_count":null,"outputs":[]}]}