{"metadata":{"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":67836,"databundleVersionId":7527339,"sourceType":"competition"},{"sourceId":7601980,"sourceType":"datasetVersion","datasetId":4425551}],"dockerImageVersionId":30648,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.12.0"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Minimum Working Solution DL Engima 1.0","metadata":{}},{"cell_type":"markdown","source":"#### This notebook was inspired from [here](https://www.kaggle.com/code/sameen53/yolov8-minimum-working-sample)","metadata":{}},{"cell_type":"code","source":"# basic libraries ...\n\nimport os\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom tqdm import tqdm","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:04.028624Z","iopub.status.busy":"2024-02-10T06:28:04.02817Z","iopub.status.idle":"2024-02-10T06:28:04.033393Z","shell.execute_reply":"2024-02-10T06:28:04.032325Z","shell.execute_reply.started":"2024-02-10T06:28:04.028597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# yolo ...\n\nfrom ultralytics import YOLO","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:16.559071Z","iopub.status.busy":"2024-02-10T06:28:16.558684Z","iopub.status.idle":"2024-02-10T06:28:16.56499Z","shell.execute_reply":"2024-02-10T06:28:16.564004Z","shell.execute_reply.started":"2024-02-10T06:28:16.559036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# # # delete all the files and directories recursively in the current working directory ...\n\n# !rm -rf './data'","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:16.567883Z","iopub.status.busy":"2024-02-10T06:28:16.56746Z","iopub.status.idle":"2024-02-10T06:28:18.287546Z","shell.execute_reply":"2024-02-10T06:28:18.286249Z","shell.execute_reply.started":"2024-02-10T06:28:16.567847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import os\n# import shutil\n# import random\n\n# random.seed(112)\n\n# def create_directories_if_not_exist(directory):\n#     os.makedirs(directory, exist_ok=True)\n\n# def move_files_by_ratio(source_dir, dest_dir, ratio):\n#     files = os.listdir(source_dir)\n#     random.shuffle(files)\n#     total_files = len(files)\n#     target_files = int(total_files * ratio)\n#     moved_files = 0\n#     moved_base_names = []\n\n#     for file_name in tqdm(files):\n#         source_path = os.path.join(source_dir, file_name)\n#         dest_path = os.path.join(dest_dir, file_name)\n#         shutil.move(source_path, dest_path)\n#         moved_files += 1\n#         moved_base_names.append(os.path.splitext(file_name)[0])\n#         if moved_files >= target_files: break\n    \n#     return moved_base_names\n\n# def copy_files_by_ratio(source_dir, dest_dir, ratio):\n#     files = os.listdir(source_dir)\n#     random.shuffle(files)\n#     total_files = len(files)\n#     target_files = int(total_files * ratio)\n#     copied_files = 0\n#     copied_base_names = []\n\n#     for file_name in tqdm(files):\n#         source_path = os.path.join(source_dir, file_name)\n#         dest_path = os.path.join(dest_dir, file_name)\n#         shutil.copy(source_path, dest_path)\n#         copied_files += 1\n#         copied_base_names.append(os.path.splitext(file_name)[0])\n#         if copied_files >= target_files: break\n    \n#     return copied_base_names\n\n# def move_files_by_basename(source_dir, dest_dir, base_names):\n#     for base_name in tqdm(base_names):\n#         source_label_path = os.path.join(source_dir, base_name + \".txt\")\n#         dest_label_path = os.path.join(dest_dir, base_name + \".txt\")\n#         shutil.move(source_label_path, dest_label_path)\n\n# def copy_files_by_basename(source_dir, dest_dir, base_names):\n#     for base_name in tqdm(base_names):\n#         source_label_path = os.path.join(source_dir, base_name + \".txt\")\n#         dest_label_path = os.path.join(dest_dir, base_name + \".txt\")\n#         shutil.copy(source_label_path, dest_label_path)\n\n# source_image_dir = \"./dlenigma1/BadODD/images/train\"\n# source_label_dir = \"./dlenigma1/BadODD/labels/train\"\n# dest_image_dir = \"./data/images/train\"\n# dest_label_dir = \"./data/labels/train\"\n\n# create_directories_if_not_exist(dest_image_dir)\n# create_directories_if_not_exist(dest_label_dir)\n# copied_base_names = copy_files_by_ratio(source_image_dir, dest_image_dir, 1)\n# copy_files_by_basename(source_label_dir, dest_label_dir, copied_base_names)\n\n# source_image_dir = dest_image_dir\n# source_label_dir = dest_label_dir\n# dest_image_dir = \"./data/images/val\"\n# dest_label_dir = \"./data/labels/val\"\n\n# create_directories_if_not_exist(dest_image_dir)\n# create_directories_if_not_exist(dest_label_dir)\n# moved_base_names = move_files_by_ratio(source_image_dir, dest_image_dir, 0.2)\n# move_files_by_basename(source_label_dir, dest_label_dir, moved_base_names)\n\n# source_image_dir = \"./dlenigma1/BadODD/images/test\"\n# dest_image_dir = \"./data/images/test\"\n\n# create_directories_if_not_exist(dest_image_dir)\n# copied_base_names = copy_files_by_ratio(source_image_dir, dest_image_dir, 1)","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:18.289158Z","iopub.status.busy":"2024-02-10T06:28:18.288868Z","iopub.status.idle":"2024-02-10T06:28:51.109518Z","shell.execute_reply":"2024-02-10T06:28:51.108538Z","shell.execute_reply.started":"2024-02-10T06:28:18.28913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_names = [\n    'auto_rickshaw',\n    'bicycle',\n    'bus',\n    'car',\n    'cart_vehicle',\n    'construction_vehicle',\n    'motorbike',\n    'person',\n    'priority_vehicle',\n    'three_wheeler',\n    'train',\n    'truck',\n    'wheelchair'\n]","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:52.106157Z","iopub.status.busy":"2024-02-10T06:28:52.105837Z","iopub.status.idle":"2024-02-10T06:28:52.111732Z","shell.execute_reply":"2024-02-10T06:28:52.110693Z","shell.execute_reply.started":"2024-02-10T06:28:52.106129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import os\n# from PIL import Image, ImageOps\n# import torch\n# from torch.utils.data import Dataset\n# from torchvision import transforms\n\n# class ObjectDataset(Dataset):\n#     def __init__(self, image_dir, label_dir, image_transform=None, label_transform=None, image_format='jpg', label_format='txt'):\n#         self.image_dir = image_dir\n#         self.label_dir = label_dir\n#         self.image_transform = image_transform\n#         self.label_transform = label_transform\n#         self.image_format = image_format\n#         self.label_format = label_format\n\n#         self.file_names = []\n#         self.label_map = {}\n#         image_base_names = [os.path.splitext(file_name)[0] for file_name in os.listdir(image_dir) if file_name.endswith('.' + image_format)]\n#         label_base_names = [os.path.splitext(file_name)[0] for file_name in os.listdir(label_dir) if file_name.endswith('.' + label_format)]\n#         for base_name in image_base_names:\n#             if base_name in label_base_names:\n#                 self.file_names.append(base_name)\n#                 self.label_map[base_name] = self._parse_labels(os.path.join(label_dir, base_name + '.' + label_format))\n\n#     def __len__(self):\n#         return len(self.file_names)\n\n#     def __getitem__(self, idx):\n#         base_name = self.file_names[idx]\n#         img_path = os.path.join(self.image_dir, base_name + '.' + self.image_format)\n\n#         image = Image.open(img_path).convert('RGB')\n#         target = self.get_target(idx)\n\n#         if self.image_transform: image = self.image_transform(image)\n#         if self.label_transform: target = self.label_transform(label)\n\n#         return image, target\n    \n# #     def _resize_image(self, image):\n# #         aspect_ratio = image.width / image.height\n\n# #         if aspect_ratio > 16 / 9:\n# #             desired_height = int(image.width * 9 / 16)\n# #             padding = (0, (desired_height - image.height) // 2)\n# #             new_image = ImageOps.expand(image, (0, padding[1], 0, padding[1]), fill=\"black\")\n# #         elif aspect_ratio < 16 / 9:\n# #             desired_width = int(image.height * 16 / 9)\n# #             padding = ((desired_width - image.width) // 2, 0)\n# #             new_image = ImageOps.expand(image, (padding[0], 0, padding[0], 0), fill=\"black\")\n# #         else:\n# #             new_image = image.copy()\n\n# #         return new_image\n    \n#     def _parse_labels(self, label_path):\n#         target = {'boxes': [], 'labels': [], 'image_id': 0, 'area': [], 'iscrowd': []}\n\n#         with open(label_path, 'r') as file:\n#             for line in file:\n#                 parts = line.strip().split()\n#                 label = int(parts[0])\n#                 x_mid, y_mid, width, height = map(float, parts[1:])\n\n#                 box = self.toXYXY([x_mid, y_mid, width, height])\n\n#                 target['boxes'].append(box)\n#                 target['labels'].append(label)\n#                 target['image_id'] = self.file_names.index(os.path.splitext(os.path.basename(label_path))[0])\n#                 target['area'].append(width * height)\n#                 target['iscrowd'].append(0)\n\n#         return target\n\n#     @staticmethod\n#     def toXYXY(box):\n#         x_mid, y_mid, width, height = box\n#         x_min = x_mid - width / 2\n#         y_min = y_mid - height / 2\n#         x_max = x_mid + width / 2\n#         y_max = y_mid + height / 2\n\n#         return [x_min, y_min, x_max, y_max]\n\n#     @staticmethod\n#     def toXYWH(box):\n#         x_min, y_min, x_max, y_max = box\n#         x_mid = (x_min + x_max) / 2\n#         y_mid = (y_min + y_max) / 2\n#         width = x_max - x_min\n#         height = y_max - y_min\n\n#         return [x_mid, y_mid, width, height]\n    \n#     def get_target(self, idx):\n#         base_name = self.file_names[idx]\n#         return self.label_map[base_name]","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:52.113915Z","iopub.status.busy":"2024-02-10T06:28:52.11361Z","iopub.status.idle":"2024-02-10T06:28:52.134284Z","shell.execute_reply":"2024-02-10T06:28:52.133123Z","shell.execute_reply.started":"2024-02-10T06:28:52.11389Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from torch.utils.data import Dataset, Subset\n\n# def balance_classes(dataset, num_classes, target_count):\n#     if isinstance(dataset, Subset):\n#         original_dataset = dataset.dataset\n#         dataset_indices = dataset.indices\n#     else:\n#         original_dataset = dataset\n#         dataset_indices = range(len(dataset))\n\n#     class_counts = [0] * num_classes\n#     class_indices = [[] for _ in range(num_classes)]\n\n#     for i, index in tqdm(enumerate(dataset_indices)):\n#         labels = original_dataset.get_target(index)['labels']\n            \n#         for class_id in labels:\n#             class_indices[class_id].append(index)\n#             class_counts[class_id] += 1\n\n#     new_indices = []\n\n#     for class_id, count in tqdm(enumerate(class_counts)):\n#         if(count==0 or count >= target_count): continue\n        \n#         duplicate_indices = [random.choice(class_indices[class_id]) for _ in range(target_count - count)]\n#         new_indices += duplicate_indices\n\n#     return Subset(original_dataset, list(dataset_indices) + new_indices)","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:52.138881Z","iopub.status.busy":"2024-02-10T06:28:52.138518Z","iopub.status.idle":"2024-02-10T06:28:52.14863Z","shell.execute_reply":"2024-02-10T06:28:52.147668Z","shell.execute_reply.started":"2024-02-10T06:28:52.138851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import pandas as pd\n\n# image_root_dir = './data/images'\n# label_root_dir = './data/labels'\n\n# photometric_transforms = transforms.RandomOrder([\n#     transforms.GaussianBlur(kernel_size=5),\n#     transforms.RandomChoice([transforms.RandomAdjustSharpness(sharpness_factor=0.5),\n#                              transforms.RandomAdjustSharpness(sharpness_factor=2)],\n#                            p=[0.33, 0.33]),\n#     transforms.RandomEqualize(),\n#     transforms.ColorJitter(brightness=0.4, contrast=0.4),\n# #     transforms.RandomPosterize(bits=2)\n# ])\n\n# image_transform = transforms.Compose([\n#     photometric_transforms,\n# #     transforms.Resize(size=(1080, 1920)),\n#     transforms.ToTensor(),\n# ])\n# label_transform = None\n\n# df = pd.DataFrame(columns=['Class'])\n# df['Class'] = class_names\n\n# data_split = {}\n# splits = ['Train', 'Val']\n# expected_class_count = {\n#     'Train': 1000,\n#     'Val': 100,\n# }\n\n# for split in splits:\n#     image_dir = image_root_dir + '/' + split.lower()\n#     label_dir = label_root_dir + '/' + split.lower()\n\n#     dataset = ObjectDataset(image_dir, label_dir, image_transform, label_transform)\n#     data_split[split] = balance_classes(dataset, 13, expected_class_count[split])\n\n#     counts = {}\n\n#     for i in tqdm(range(len(data_split[split]))):\n#         idx = data_split[split].indices[i]\n#         labels = data_split[split].dataset.get_target(idx)['labels']\n\n#         for label in labels:\n#             class_name = class_names[label]\n#             if class_name in counts: counts[class_name] += 1\n#             else: counts[class_name] = 1\n\n#     sorted_counts = dict(sorted(counts.items()))\n#     df[split + ' Count'] = [sorted_counts.get(class_name, 0) for class_name in class_names]\n\n# display(df)","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:52.150495Z","iopub.status.busy":"2024-02-10T06:28:52.149937Z","iopub.status.idle":"2024-02-10T06:28:55.050772Z","shell.execute_reply":"2024-02-10T06:28:55.049912Z","shell.execute_reply.started":"2024-02-10T06:28:52.150458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# tensor_to_image = transforms.ToPILImage()\n\n# tensor1, target1 = data_split['Train'][0]\n# image1 = tensor_to_image(tensor1)\n\n# transformed_images = [photometric_transforms(image1) for _ in range(15)]\n\n# fig, axes = plt.subplots(4, 4, figsize=(16, 16))\n# for i, ax in enumerate(axes.flat):\n#     image = transformed_images[i-1] if i>0 else image1\n#     ax.imshow(image)\n#     ax.axis('off')\n\n# plt.tight_layout()\n# plt.show()","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:28:55.052406Z","iopub.status.busy":"2024-02-10T06:28:55.052045Z","iopub.status.idle":"2024-02-10T06:29:06.036574Z","shell.execute_reply":"2024-02-10T06:29:06.035142Z","shell.execute_reply.started":"2024-02-10T06:28:55.052377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Weights & Biases ...\n\nimport wandb\nwandb.init(mode=\"disabled\")","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:29:06.038185Z","iopub.status.busy":"2024-02-10T06:29:06.037881Z","iopub.status.idle":"2024-02-10T06:29:07.752177Z","shell.execute_reply":"2024-02-10T06:29:07.751175Z","shell.execute_reply.started":"2024-02-10T06:29:06.038158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# def save_dataset(dataset, image_dir, label_dir):\n#     os.makedirs(image_dir, exist_ok=True)\n#     os.makedirs(label_dir, exist_ok=True)\n\n#     for i, (tensor, targets) in tqdm(enumerate(dataset)):\n#         filename = dataset.dataset.file_names[dataset.indices[i]]\n#         image_filename = os.path.join(image_dir, f'{filename}-{i}.jpg')\n#         label_filename = os.path.join(label_dir, f'{filename}-{i}.txt')\n\n#         image = tensor_to_image(tensor)\n#         image.save(image_filename)\n\n#         with open(label_filename, 'w') as f:\n#             for box, label in zip(targets['boxes'], targets['labels']):\n#                 x_mid, y_mid, width, height = ObjectDataset.toXYWH(box)\n#                 label_str = f\"{label} {x_mid} {y_mid} {width} {height}\\n\"\n#                 f.write(label_str)\n\n#     print(\"Dataset saved successfully.\")","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:29:07.807923Z","iopub.status.busy":"2024-02-10T06:29:07.807657Z","iopub.status.idle":"2024-02-10T06:29:07.82088Z","shell.execute_reply":"2024-02-10T06:29:07.820032Z","shell.execute_reply.started":"2024-02-10T06:29:07.8079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# image_root_dir = './new_data/images'\n# label_root_dir = './new_data/labels'\n\n# for split in splits:\n#     image_dir = image_root_dir + '/' + split.lower()\n#     label_dir = label_root_dir + '/' + split.lower()\n    \n#     save_dataset(data_split[split], image_dir, label_dir)","metadata":{"execution":{"iopub.execute_input":"2024-02-10T06:29:07.822331Z","iopub.status.busy":"2024-02-10T06:29:07.822031Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# configuration file that tells YOLO where to find the dataset and what objects to detect ...\n\nfile_content = \"\"\"\npath: ./new_data\ntrain: images/train\nval: images/val\ntest: images/test\n\n# Classes\nnames:\n    0: auto_rickshaw\n    1: bicycle\n    2: bus\n    3: car\n    4: cart_vehicle\n    5: construction_vehicle\n    6: motorbike\n    7: person\n    8: priority_vehicle\n    9: three_wheeler\n    10: train\n    11: truck\n    12: wheelchair\n\"\"\"\n\nwith open(\"./data.yaml\", mode=\"w\") as f:\n    f.write(file_content)","metadata":{"execution":{"iopub.execute_input":"2024-02-10T08:01:19.515216Z","iopub.status.busy":"2024-02-10T08:01:19.514926Z","iopub.status.idle":"2024-02-10T08:01:19.520977Z","shell.execute_reply":"2024-02-10T08:01:19.519972Z","shell.execute_reply.started":"2024-02-10T08:01:19.515191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_content = \"\"\"\nseed: 138\nimgsz: 1080\n\naugment: True\ndegrees: 10\nshear: 10\ntranslate: 0.25\nperspective: 0.001\n\npatience: 20\nepochs: 40\n\"\"\"\n\nwith open(\"./config.yaml\", mode=\"w\") as f:\n    f.write(file_content)","metadata":{"execution":{"iopub.execute_input":"2024-02-10T08:26:44.451742Z","iopub.status.busy":"2024-02-10T08:26:44.451322Z","iopub.status.idle":"2024-02-10T08:26:44.457321Z","shell.execute_reply":"2024-02-10T08:26:44.456294Z","shell.execute_reply.started":"2024-02-10T08:26:44.451712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = YOLO(\"yolov8m.pt\")","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.train(\n    data=\"./data.yaml\",\n    cfg=\"./config.yaml\",\n)","metadata":{"execution":{"iopub.execute_input":"2024-02-10T08:27:48.516682Z","iopub.status.busy":"2024-02-10T08:27:48.516252Z","iopub.status.idle":"2024-02-10T08:27:48.826393Z","shell.execute_reply":"2024-02-10T08:27:48.824337Z","shell.execute_reply.started":"2024-02-10T08:27:48.516649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# get prediction boxes string according to the submission format ...\n\ndef get_prediction_string(boxes, scores, classes):\n    pred_strs = []\n    for i, score in enumerate(scores):\n        single_pred_str = \"\"\n        single_pred_str += str(float(classes[i])) + \" \" + str(float(score)) + \" \"\n        \n        x_center , y_center, width,height = boxes[i]\n        x1 = float(x_center) - (float(width) / 2)\n        y1 = float(y_center) - (float(height) / 2)\n        width = float(width)\n        height = float(height)\n        #single_pred_str += \" \".join(str(float(x)) for x in boxes[i])\n        single_pred_str +=  f\"{x1} {y1} {width} {height}\"\n        \n        pred_strs.append(single_pred_str)\n    ans = ','.join(map(str, pred_strs))\n    if len(ans):\n        return ans\n#     the solution metrics faield in case of a NaN, '' (empty). So, return \"0 0 0 0 0 0\" for NaN, '' (empty) string\n    return \"0 0 0 0 0 0\"\n\n# get the predcition in id, ImageID, PredictionString_pred foramt ...\n\ndef get_prediction_entry(i, filename, boxes, scores, classes):\n    return {\n        \"id\": i, # strating from 0 ...\n        \"ImageID\": filename.split('.')[0], # before the extension ...\n        \"PredictionString_pred\": get_prediction_string(boxes, scores, classes)\n    }\n\n# Directory path ...\ntest_directory = \"./dlenigma1/BadODD/images/test\"\n\n# Load the model ...\nmodel = YOLO('./runs/detect/train14/weights/best.pt')\n\n# do the inference ...\n\ndef predict_all_files(test_directory):\n    predictions = []\n    for i,filename in tqdm(enumerate(os.listdir(test_directory))):\n        if filename.endswith(\".jpg\"):\n            filepath = os.path.join(test_directory, filename)\n            results = model.predict(source=filepath, conf=0.50, verbose=False)\n            boxes = results[0].boxes.xywhn\n            scores = results[0].boxes.conf\n            classes = results[0].boxes.cls\n            prediction = get_prediction_entry(i, filename, boxes, scores, classes)\n            predictions.append(prediction)\n#             to csv format ...\n    predictions_df = pd.DataFrame(predictions)\n    predictions_df.to_csv(\"./submission.csv\", index=False)\n\n# call the inference function ...\npredict_all_files(test_directory)","metadata":{"execution":{"iopub.status.busy":"2024-02-10T08:27:48.827542Z","iopub.status.idle":"2024-02-10T08:27:48.828011Z","shell.execute_reply":"2024-02-10T08:27:48.827793Z","shell.execute_reply.started":"2024-02-10T08:27:48.82777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# load the submission dataframe ....\n\nsubmission_df = pd.read_csv('./submission.csv')","metadata":{"execution":{"iopub.status.busy":"2024-02-10T08:27:48.829252Z","iopub.status.idle":"2024-02-10T08:27:48.829653Z","shell.execute_reply":"2024-02-10T08:27:48.8295Z","shell.execute_reply.started":"2024-02-10T08:27:48.829484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview ...\n\nsubmission_df.tail()","metadata":{"execution":{"iopub.status.busy":"2024-02-10T08:27:48.831514Z","iopub.status.idle":"2024-02-10T08:27:48.832234Z","shell.execute_reply":"2024-02-10T08:27:48.832001Z","shell.execute_reply.started":"2024-02-10T08:27:48.831981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# dataframe shape ...\n\nsubmission_df.shape","metadata":{"execution":{"iopub.status.busy":"2024-02-10T08:27:48.833462Z","iopub.status.idle":"2024-02-10T08:27:48.833897Z","shell.execute_reply":"2024-02-10T08:27:48.833684Z","shell.execute_reply.started":"2024-02-10T08:27:48.833666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# any null value? ...\n\nsubmission_df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2024-02-10T08:27:48.834877Z","iopub.status.idle":"2024-02-10T08:27:48.835327Z","shell.execute_reply":"2024-02-10T08:27:48.835102Z","shell.execute_reply.started":"2024-02-10T08:27:48.835084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# acceptable submission format ...\n\nsubmission_df.to_csv('./acceptable_submission_format.csv',index=False)","metadata":{"execution":{"iopub.status.busy":"2024-02-10T08:27:48.836697Z","iopub.status.idle":"2024-02-10T08:27:48.837132Z","shell.execute_reply":"2024-02-10T08:27:48.836916Z","shell.execute_reply.started":"2024-02-10T08:27:48.836898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}