{"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":"markdown","source":"# Explore 🕵 provdided data","metadata":{}},{"cell_type":"code","source":"!ls -l /kaggle/input/happy-whale-and-dolphin\n\nPATH_DATASET = \"/kaggle/input/happy-whale-and-dolphin\"","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-03T14:42:13.814931Z","iopub.execute_input":"2022-03-03T14:42:13.815454Z","iopub.status.idle":"2022-03-03T14:42:14.601700Z","shell.execute_reply.started":"2022-03-03T14:42:13.815294Z","shell.execute_reply":"2022-03-03T14:42:14.600692Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\ndf_train = pd.read_csv(os.path.join(PATH_DATASET, \"train.csv\"))\ndisplay(df_train.head())\nprint(f\"Dataset size: {len(df_train)}\")\nprint(f\"Unique ids: {len(df_train['individual_id'].unique())}\")","metadata":{"execution":{"iopub.status.busy":"2022-03-03T14:42:14.605531Z","iopub.execute_input":"2022-03-03T14:42:14.606255Z","iopub.status.idle":"2022-03-03T14:42:15.803196Z","shell.execute_reply.started":"2022-03-03T14:42:14.606215Z","shell.execute_reply":"2022-03-03T14:42:15.802312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Lets see how top individulas we have in the database...","metadata":{}},{"cell_type":"code","source":"top_ = df_train[\"individual_id\"].value_counts()\nax = top_[:50].plot.barh(figsize=(3, 8), grid=True)  # ascending=True","metadata":{"execution":{"iopub.status.busy":"2022-03-03T14:44:55.405101Z","iopub.execute_input":"2022-03-03T14:44:55.405424Z","iopub.status.idle":"2022-03-03T14:44:56.363113Z","shell.execute_reply.started":"2022-03-03T14:44:55.405388Z","shell.execute_reply":"2022-03-03T14:44:56.362233Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display(top_[:4])\ntop_ids = list(top_[:4].index) + ['new_individual']\nprint(top_ids)","metadata":{"execution":{"iopub.status.busy":"2022-03-03T14:47:00.220722Z","iopub.execute_input":"2022-03-03T14:47:00.221530Z","iopub.status.idle":"2022-03-03T14:47:00.229967Z","shell.execute_reply.started":"2022-03-03T14:47:00.221491Z","shell.execute_reply":"2022-03-03T14:47:00.229003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Static 📥 submission","metadata":{}},{"cell_type":"code","source":"!head ../input/happy-whale-and-dolphin/sample_submission.csv","metadata":{"execution":{"iopub.status.busy":"2022-03-03T14:55:41.347177Z","iopub.execute_input":"2022-03-03T14:55:41.348192Z","iopub.status.idle":"2022-03-03T14:55:42.141401Z","shell.execute_reply.started":"2022-03-03T14:55:41.348136Z","shell.execute_reply":"2022-03-03T14:55:42.140563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import glob\n\nimgs = glob.glob(\"/kaggle/input/happy-whale-and-dolphin/test_images/*.jpg\")\nimgs = list(map(os.path.basename, imgs))\nprint(imgs[:5])","metadata":{"execution":{"iopub.status.busy":"2022-03-03T14:50:52.073466Z","iopub.execute_input":"2022-03-03T14:50:52.074260Z","iopub.status.idle":"2022-03-03T14:50:52.216347Z","shell.execute_reply.started":"2022-03-03T14:50:52.074209Z","shell.execute_reply":"2022-03-03T14:50:52.215762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = list(zip(imgs, [\" \".join(top_ids)] * len(imgs)))\npd.DataFrame(submission, columns=[\"image\",\"predictions\"]).set_index(\"image\").to_csv(\"submission.csv\")\n!head submission.csv","metadata":{"execution":{"iopub.status.busy":"2022-03-03T14:56:30.796112Z","iopub.execute_input":"2022-03-03T14:56:30.796509Z","iopub.status.idle":"2022-03-03T14:56:31.727217Z","shell.execute_reply.started":"2022-03-03T14:56:30.796438Z","shell.execute_reply":"2022-03-03T14:56:31.726194Z"},"trusted":true},"execution_count":null,"outputs":[]}]}