{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import math\nimport numpy as np\nimport pandas as pd\n# import h5py\nimport matplotlib.pyplot as plt\n# import scipy\n# from PIL import Image\nfrom scipy import ndimage\nimport tensorflow as tf\nfrom tensorflow.python.framework import ops\n# from cnn_utils import *\nimport pydicom\n%matplotlib inline\nimport glob\nimport os\nimport cv2\nfrom numpy import random\nfrom tensorflow.keras.constraints import unit_norm, max_norm\n# from IPython.core.interactiveshell import InteractiveShell\n\n# InteractiveShell.ast_node_interactivity = \"all\"","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:12:43.067067Z","iopub.execute_input":"2021-10-07T15:12:43.067534Z","iopub.status.idle":"2021-10-07T15:12:48.415665Z","shell.execute_reply.started":"2021-10-07T15:12:43.067453Z","shell.execute_reply":"2021-10-07T15:12:48.415010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"empt_arr = np.empty((585*4,150,150, 40), 'uint8')\n\nrow_no = 0\nchannel = 0\n\npath = \"../input/rsna-miccai-brain-tumor-radiogenomic-classification/train\"\n\nfolders = [\"FLAIR\",\"T2w\",\"T1w\",\"T1wCE\"]\n\n# for folder in folder:\nfor folder in folders:\n    print(\"Folder started -----------------------------:\", folder)\n    for i in range(0,1011):\n        a = '00000' + str(i)\n\n        path_flair = sorted(glob.glob(os.path.join(path, a[-5:] , folder, '*')), \n                       key = lambda x : int(x[:-4].split(\"-\")[-1]))\n        leth =  len(path_flair)\n#         print(\"length of folder\" + str(len(path_flair)))\n        \n        k1 = len(glob.glob(os.path.join(path, a[-5:] , \"FLAIR\", '*')))\n        k2 = len(glob.glob(os.path.join(path, a[-5:] , \"T2w\", '*')))\n        k3 = len(glob.glob(os.path.join(path, a[-5:] , \"T1w\", '*')))\n        k4 = len(glob.glob(os.path.join(path, a[-5:] , \"T1w\", '*')))\n\n        if k1 == 0 and k2 == 0 and k3 == 0 and k4 == 0:\n            continue\n#         print(\"folder number: \" + str(a[-5:]))\n\n        for i in range(len(path_flair)):\n                if (i+1)%7 == 0 and i > 0: \n#                     print(\"image number---\",i)\n                    dicom_arr = pydicom.dcmread(path_flair[i])\n                    dicom_arr = dicom_arr.pixel_array\n                    dicom_arr = dicom_arr[100:400,100:400]\n                    dicom_arr = cv2.resize(dicom_arr, (0, 0), fx = 0.5, fy = 0.5)\n\n                    dicom_arr = dicom_arr - np.min(dicom_arr)\n                    if np.max(dicom_arr) != 0:\n                        dicom_arr = dicom_arr / (np.max(dicom_arr) - np.min(dicom_arr))\n                        dicom_arr = dicom_arr * 255\n                        \n#                         print(\"image shape:\", dicom_arr.shape)\n                        a,b = dicom_arr.shape\n                        if a < 150 or b < 150:\n                            empt_arr[row_no,0:a,0:b,channel] = dicom_arr \n                        else:\n                            empt_arr[row_no,:,:,channel] = dicom_arr\n#                         print(\"channel number---\", channel)\n                        if channel == 39:\n                            break\n                        channel += 1\n                    \n        channel = 0\n#         print(\"channel reset----------------------\", channel)\n        row_no += 1\n#         print(\"Row number----------------------\", row_no)\n        \n                             \n                ","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:12:48.417432Z","iopub.execute_input":"2021-10-07T15:12:48.418074Z","iopub.status.idle":"2021-10-07T15:19:34.496125Z","shell.execute_reply.started":"2021-10-07T15:12:48.418009Z","shell.execute_reply":"2021-10-07T15:19:34.495207Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# ../input/rsna-miccai-brain-tumor-radiogenomic-classification/train_labels.csv\n# ../input/train-labels ../input/train-labels/train_labels.csv\nTrain_Y = pd.read_csv('../input/rsna-miccai-brain-tumor-radiogenomic-classification/train_labels.csv', encoding = 'utf-8')\n# Train_Y","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:34.497230Z","iopub.execute_input":"2021-10-07T15:19:34.497435Z","iopub.status.idle":"2021-10-07T15:19:34.520393Z","shell.execute_reply.started":"2021-10-07T15:19:34.497411Z","shell.execute_reply":"2021-10-07T15:19:34.519583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Train_Y1 = list(Train_Y[\"MGMT_value\"])\nTrain_Y2 = Train_Y1*4","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:34.522577Z","iopub.execute_input":"2021-10-07T15:19:34.522904Z","iopub.status.idle":"2021-10-07T15:19:34.534649Z","shell.execute_reply.started":"2021-10-07T15:19:34.522863Z","shell.execute_reply":"2021-10-07T15:19:34.533355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Train_Y3 = np.array(Train_Y2)\n# Train_Y3.shape","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:34.536389Z","iopub.execute_input":"2021-10-07T15:19:34.536856Z","iopub.status.idle":"2021-10-07T15:19:34.547630Z","shell.execute_reply.started":"2021-10-07T15:19:34.536825Z","shell.execute_reply":"2021-10-07T15:19:34.546925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from tensorflow.keras.constraints import unit_norm, max_norm\n\n# cons = 5.\n# init = 'HeUniform'\ndef forward_propagation(H,W,C):\n    tf.compat.v1.set_random_seed(3) \n    model = tf.keras.Sequential(name=\"RSNA\")\n    model.add(tf.keras.layers.InputLayer(input_shape=(H,W,C)))\n    model.add(tf.keras.layers.Conv2D(filters = 16, kernel_size = (5,5),kernel_constraint = max_norm(5.), kernel_regularizer=regularizers.l2(0.001),strides=(1, 1), padding='same',activation = 'relu',kernel_initializer='HeUniform'))\n    model.add(tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=(1,1), padding='same'))\n    model.add(tf.keras.layers.Dropout(0.5))\n    #Layer2\n    model.add(tf.keras.layers.Conv2D(filters = 32, kernel_size = (3,3),kernel_constraint=max_norm(5.), kernel_regularizer=regularizers.l2(0.001),strides=(1, 1), padding='same',activation = 'relu',kernel_initializer='HeUniform'))\n    model.add(tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=(1,1), padding='same'))\n    #Dropout\n    model.add(tf.keras.layers.Dropout(0.5))\n    \n    #FLATTEN\n    model.add(tf.keras.layers.Flatten()) \n#               kernel_regularizer=regularizers.l2(0.001)\n    #FC OR DENSELY CONNECTED\n    model.add(tf.keras.layers.Dense(512, activation='relu',kernel_regularizer=regularizers.l2(0.0001),kernel_constraint=max_norm(10.),kernel_initializer='HeUniform'))\n    model.add(tf.keras.layers.Dropout(0.2))\n    model.add(tf.keras.layers.Dense(256, activation='relu',kernel_regularizer=regularizers.l2(0.0001),kernel_constraint=max_norm(10.),kernel_initializer='HeUniform'))\n    model.add(tf.keras.layers.Dropout(0.2))\n    model.add(tf.keras.layers.Dense(2, activation='softmax',kernel_initializer='he_normal'))  \n    \n    #compile\n#     model.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])\n#     model.fit(X_train,Y_train,epochs=10,batch_size=32,validation_split=0.1,verbose = 1)\n#     model.output_shape\n    return model","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:34.549116Z","iopub.execute_input":"2021-10-07T15:19:34.549759Z","iopub.status.idle":"2021-10-07T15:19:34.564769Z","shell.execute_reply.started":"2021-10-07T15:19:34.549729Z","shell.execute_reply":"2021-10-07T15:19:34.563513Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nH, W, C = empt_arr.shape[1:]\nH, W, C","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:34.565951Z","iopub.execute_input":"2021-10-07T15:19:34.566461Z","iopub.status.idle":"2021-10-07T15:19:34.584850Z","shell.execute_reply.started":"2021-10-07T15:19:34.566407Z","shell.execute_reply":"2021-10-07T15:19:34.584314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#compile\nfrom tensorflow.python.keras import regularizers\n# H, W, C = X_train.shape[1:]     \nmodel = forward_propagation(H, W, C)\nmodel.compile(loss='categorical_crossentropy',optimizer='adam',\n              metrics=['accuracy',tf.keras.metrics.Precision(),tf.keras.metrics.Recall()])","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:34.585674Z","iopub.execute_input":"2021-10-07T15:19:34.586452Z","iopub.status.idle":"2021-10-07T15:19:34.594792Z","shell.execute_reply.started":"2021-10-07T15:19:34.586418Z","shell.execute_reply":"2021-10-07T15:19:34.594229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.utils import to_categorical\nY_train4 = to_categorical(Train_Y3, num_classes=2)\nY_train4.shape, empt_arr.shape","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:34.596427Z","iopub.execute_input":"2021-10-07T15:19:34.597145Z","iopub.status.idle":"2021-10-07T15:19:34.614144Z","shell.execute_reply.started":"2021-10-07T15:19:34.597114Z","shell.execute_reply":"2021-10-07T15:19:34.613216Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from tensorflow.python.keras import regularizers\n# # detect and init the TPU\n# tpu = tf.distribute.cluster_resolver.TPUClusterResolver.connect()\n\n# # instantiate a distribution strategy\n# tpu_strategy = tf.distribute.experimental.TPUStrategy(tpu)\n\n# # instantiating the model in the strategy scope creates the model on the TPU\n# with tpu_strategy.scope():\n#     model = forward_propagation(H, W, C)\n#     model.compile(loss='categorical_crossentropy',optimizer='adam',\n#               metrics=['accuracy',tf.keras.metrics.Precision(),tf.keras.metrics.Recall()])\n\n# # train model normally\n# # model.fit(training_dataset, epochs=EPOCHS, steps_per_epoch=…)","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:34.615671Z","iopub.execute_input":"2021-10-07T15:19:34.615878Z","iopub.status.idle":"2021-10-07T15:19:45.925642Z","shell.execute_reply.started":"2021-10-07T15:19:34.615854Z","shell.execute_reply":"2021-10-07T15:19:45.924884Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(empt_arr, Y_train4,epochs=30,batch_size=32,validation_split=0.1,verbose = 1)","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:19:45.926789Z","iopub.execute_input":"2021-10-07T15:19:45.926995Z","iopub.status.idle":"2021-10-07T15:25:07.566127Z","shell.execute_reply.started":"2021-10-07T15:19:45.926971Z","shell.execute_reply":"2021-10-07T15:25:07.565273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# model.summary()","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:25:55.680768Z","iopub.execute_input":"2021-10-07T15:25:55.681074Z","iopub.status.idle":"2021-10-07T15:25:55.684310Z","shell.execute_reply.started":"2021-10-07T15:25:55.681018Z","shell.execute_reply":"2021-10-07T15:25:55.683650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# history.history.keys()","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:25:56.799812Z","iopub.execute_input":"2021-10-07T15:25:56.800094Z","iopub.status.idle":"2021-10-07T15:25:56.803897Z","shell.execute_reply.started":"2021-10-07T15:25:56.800064Z","shell.execute_reply":"2021-10-07T15:25:56.802854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# loss = history.history['loss'][1:]\n# val_loss = history.history['val_loss'][1:]\n# epochs = range(1, len(loss) + 1)\n# plt.plot(epochs, loss, 'y', label='Training loss')\n# plt.plot(epochs, val_loss, 'r', label='Validation loss')\n# plt.title('Training and validation loss')\n# plt.xlabel('Epochs')\n# plt.ylabel('Loss')\n# plt.legend()\n# plt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:26:56.623723Z","iopub.execute_input":"2021-10-07T15:26:56.624023Z","iopub.status.idle":"2021-10-07T15:26:56.852750Z","shell.execute_reply.started":"2021-10-07T15:26:56.623985Z","shell.execute_reply":"2021-10-07T15:26:56.852102Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# # Split the train and the validation set for the fitting\n# from sklearn.model_selection import train_test_split\n# X_train1, X_val, Y_train1, Y_val = train_test_split(empt_arr, Y_train4, test_size = 0.1, random_state=2)\n# print(\"x_train shape\",X_train1.shape)\n# print(\"x_val shape\",X_val.shape)\n# print(\"y_train shape\",Y_train1.shape)\n# print(\"y_val shape\",Y_val.shape)","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:26:56.854096Z","iopub.execute_input":"2021-10-07T15:26:56.854895Z","iopub.status.idle":"2021-10-07T15:26:58.113527Z","shell.execute_reply.started":"2021-10-07T15:26:56.854853Z","shell.execute_reply":"2021-10-07T15:26:58.112608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n\n# # Predict the values from the validation dataset\n# Y_pred = model.predict(X_val)\n# # Convert predictions classes to one hot vectors \n# Y_pred_classes = tf.math.argmax(Y_pred, axis=1)\n# # Convert validation observations to one hot vectors\n# Y_true = tf.math.argmax(Y_val,axis = 1) \n# # compute the confusion matrix\n# confusion_mtx = tf.math.confusion_matrix(Y_true, Y_pred_classes) \n\n# m = tf.keras.metrics.Recall()\n# m.update_state(Y_true, Y_pred_classes)\n# m.result()\n","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:27:09.340163Z","iopub.execute_input":"2021-10-07T15:27:09.340443Z","iopub.status.idle":"2021-10-07T15:27:22.169572Z","shell.execute_reply.started":"2021-10-07T15:27:09.340414Z","shell.execute_reply":"2021-10-07T15:27:22.169022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# ds = pydicom.dcmread(os.path.join(\"../input/rsna-miccai-brain-tumor-radiogenomic-classification/test\",\"00001/FLAIR/Image-100.dcm\"))\n# ds = ds.pixel_array\n# ds = ds[100:400,100:400]\n# half = cv2.resize(ds, (0, 0), fx = 0.5, fy = 0.5)\n# half.shape,plt.imshow(half, cmap=plt.cm.bone)","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:26:01.364441Z","iopub.execute_input":"2021-10-07T15:26:01.365270Z","iopub.status.idle":"2021-10-07T15:26:01.368823Z","shell.execute_reply.started":"2021-10-07T15:26:01.365231Z","shell.execute_reply":"2021-10-07T15:26:01.367979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Test_X = np.empty((87*1,150,150, 40), 'uint8')\n\nrow_no = 0\nchannel = 0\n# ../input/rsna-miccai-brain-tumor-radiogenomic-classification/test\npath = \"../input/rsna-miccai-brain-tumor-radiogenomic-classification/test\"\n\nfolders = [\"FLAIR\"] #,\"T2w\",\"T1w\",\"T1wCE\"\n\n# for folder in folder:\nfor folder in folders:\n    print(\"Folder started -----------------------------:\", folder)\n    for i in range(0,1011):\n        a = '00000' + str(i)\n\n        path_flair = sorted(glob.glob(os.path.join(path, a[-5:] , folder, '*')), \n                       key = lambda x : int(x[:-4].split(\"-\")[-1]))\n        leth =  len(path_flair)\n#         print(\"length of folder\" + str(len(path_flair)))\n        \n        k1 = len(glob.glob(os.path.join(path, a[-5:] , \"FLAIR\", '*')))\n        k2 = len(glob.glob(os.path.join(path, a[-5:] , \"T2w\", '*')))\n        k3 = len(glob.glob(os.path.join(path, a[-5:] , \"T1w\", '*')))\n        k4 = len(glob.glob(os.path.join(path, a[-5:] , \"T1w\", '*')))\n\n        if k1 == 0 and k2 == 0 and k3 == 0 and k4 == 0:\n            continue\n#         print(\"folder number: \" + str(a[-5:]))\n\n        for i in range(len(path_flair)):\n                if (i+1)%7 == 0 and i > 0: \n#                     print(\"image number---\",i)\n                    dicom_arr = pydicom.dcmread(path_flair[i])\n                    dicom_arr = dicom_arr.pixel_array\n                    dicom_arr = dicom_arr[100:400,100:400]\n                    dicom_arr = cv2.resize(dicom_arr, (0, 0), fx = 0.5, fy = 0.5)\n\n                    dicom_arr = dicom_arr - np.min(dicom_arr)\n                    if np.max(dicom_arr) != 0:\n                        dicom_arr = dicom_arr / (np.max(dicom_arr) - np.min(dicom_arr))\n                        dicom_arr = dicom_arr * 255\n                        \n#                         print(\"image shape:\", dicom_arr.shape)\n                        a,b = dicom_arr.shape\n                        if a < 150 or b < 150:\n                            Test_X[row_no,0:a,0:b,channel] = dicom_arr \n                        else:\n                            Test_X[row_no,:,:,channel] = dicom_arr\n#                         print(\"channel number---\", channel)\n                        if channel == 39:\n                            break\n                        channel += 1\n                    \n        channel = 0\n#         print(\"channel reset----------------------\", channel)\n        row_no += 1\n#         print(\"Row number----------------------\", row_no)\n        \n                   \n#  ds = pydicom.dcmread(os.path.join(\"/kaggle/input/rsna-miccai-brain-tumor-radiogenomic-classification/train\",\"00000/FLAIR/Image-100.dcm\"))\n# ds = ds.pixel_array\n# ds = ds[100:400,100:400]\n# half = cv2.resize(ds, (0, 0), fx = 0.5, fy = 0.5)                  \n                ","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:26:01.871205Z","iopub.execute_input":"2021-10-07T15:26:01.871502Z","iopub.status.idle":"2021-10-07T15:26:17.035674Z","shell.execute_reply.started":"2021-10-07T15:26:01.871471Z","shell.execute_reply":"2021-10-07T15:26:17.034869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ID = []\npath = \"../input/rsna-miccai-brain-tumor-radiogenomic-classification/test\"\n\nfolders = [\"FLAIR\"]\n\n# for folder in folder:\nfor folder in folders:\n    \n    for i in range(0,1007):\n        a = '00000' + str(i)\n\n        path_flair = sorted(glob.glob(os.path.join(path, a[-5:] , folder, '*')), \n                       key = lambda x : int(x[:-4].split(\"-\")[-1]))\n        leth =  len(path_flair)\n        \n        \n        k1 = len(glob.glob(os.path.join(path, a[-5:] , \"FLAIR\", '*')))\n        k2 = len(glob.glob(os.path.join(path, a[-5:] , \"T2w\", '*')))\n        k3 = len(glob.glob(os.path.join(path, a[-5:] , \"T1w\", '*')))\n        k4 = len(glob.glob(os.path.join(path, a[-5:] , \"T1w\", '*')))\n\n        if k1 == 0 and k2 == 0 and k3 == 0 and k4 == 0:\n            continue\n        ID.append(str(a[-5:]))\n#         print(\"folder number: \" + str(a[-5:]))\nlen(ID)","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:26:17.039473Z","iopub.execute_input":"2021-10-07T15:26:17.039727Z","iopub.status.idle":"2021-10-07T15:26:17.554327Z","shell.execute_reply.started":"2021-10-07T15:26:17.039697Z","shell.execute_reply":"2021-10-07T15:26:17.553545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# ID","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:26:17.555555Z","iopub.execute_input":"2021-10-07T15:26:17.555779Z","iopub.status.idle":"2021-10-07T15:26:17.559714Z","shell.execute_reply.started":"2021-10-07T15:26:17.555752Z","shell.execute_reply":"2021-10-07T15:26:17.558684Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Test_X.shape","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:26:17.562484Z","iopub.execute_input":"2021-10-07T15:26:17.563087Z","iopub.status.idle":"2021-10-07T15:26:17.570885Z","shell.execute_reply.started":"2021-10-07T15:26:17.563046Z","shell.execute_reply":"2021-10-07T15:26:17.570001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Predict\n# tf.compat.v1.enable_eager_execution()\ny_pred = model.predict(Test_X)","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:26:17.571860Z","iopub.execute_input":"2021-10-07T15:26:17.572069Z","iopub.status.idle":"2021-10-07T15:26:56.621668Z","shell.execute_reply.started":"2021-10-07T15:26:17.572044Z","shell.execute_reply":"2021-10-07T15:26:56.620682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# y_pred.shape","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:27:44.750025Z","iopub.execute_input":"2021-10-07T15:27:44.750548Z","iopub.status.idle":"2021-10-07T15:27:44.755884Z","shell.execute_reply.started":"2021-10-07T15:27:44.750490Z","shell.execute_reply":"2021-10-07T15:27:44.754980Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Y_predicted = tf.math.argmax(y_pred, axis=1)\nY_predicted = np.max(y_pred, axis = 1)","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:27:54.254524Z","iopub.execute_input":"2021-10-07T15:27:54.254799Z","iopub.status.idle":"2021-10-07T15:27:54.258883Z","shell.execute_reply.started":"2021-10-07T15:27:54.254768Z","shell.execute_reply":"2021-10-07T15:27:54.258071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Y_predicted","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:27:57.338879Z","iopub.execute_input":"2021-10-07T15:27:57.339568Z","iopub.status.idle":"2021-10-07T15:27:57.347484Z","shell.execute_reply.started":"2021-10-07T15:27:57.339518Z","shell.execute_reply":"2021-10-07T15:27:57.346768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission = pd.DataFrame({'BraTS21ID': ID, 'MGMT_value': Y_predicted})\n# my_submission = pd.read_csv(f\"{data_directory}/sample_submission.csv\", dtype=str)pwd\n# ..\n# you could use any filename. We choose submission here\nmy_submission.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:28:09.574140Z","iopub.execute_input":"2021-10-07T15:28:09.574654Z","iopub.status.idle":"2021-10-07T15:28:09.585964Z","shell.execute_reply.started":"2021-10-07T15:28:09.574618Z","shell.execute_reply":"2021-10-07T15:28:09.584725Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission","metadata":{"execution":{"iopub.status.busy":"2021-10-07T15:28:11.504246Z","iopub.execute_input":"2021-10-07T15:28:11.504556Z","iopub.status.idle":"2021-10-07T15:28:11.527457Z","shell.execute_reply.started":"2021-10-07T15:28:11.504525Z","shell.execute_reply":"2021-10-07T15:28:11.526634Z"},"trusted":true},"execution_count":null,"outputs":[]}]}