{"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":"# Behavior of this notebook\n\nYou should `debug_train = False` when submit.\n\n- if (conditional statement is True): 0.16-0.17(all CC sub)\n- else: scoring error(all -1 sub)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"code","source":"from pathlib import Path\nimport pandas as pd\n\nimg_dir = Path(\"/kaggle/input/UBC-OCEAN/test_images\")\nthumbnail_dir = Path(\"/kaggle/input/UBC-OCEAN/test_thumbnails\")\ndf_path = Path(\"/kaggle/input/UBC-OCEAN/test.csv\")\n\ndebug_train = False\nif debug_train:\n    img_dir = Path(\"/kaggle/input/UBC-OCEAN/train_images\")\n    thumbnail_dir = Path(\"/kaggle/input/UBC-OCEAN/train_thumbnails\")\n    df_path = Path(\"/kaggle/input/UBC-OCEAN/train.csv\")\n\nprint(f\"img_dir: {img_dir}\")\nprint(f\"thumbnail_dir: {thumbnail_dir}\")\nprint(f\"df_path: {df_path}\")\n\ndf = pd.read_csv(df_path)\ndf[\"has_thumbnail\"] = df[\"image_id\"].apply(\n    lambda x: (thumbnail_dir / f\"{x}_thumbnail.png\").exists()\n)\n\nn_df = len(df)\nn_has_thumbnail = len(df[df[\"has_thumbnail\"]])\n\nprint(f\"n_df: {n_df}\")\nprint(f\"n_has_thumbnail: {n_has_thumbnail}\")\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2023-10-25T00:30:40.109192Z","iopub.execute_input":"2023-10-25T00:30:40.109537Z","iopub.status.idle":"2023-10-25T00:30:40.132093Z","shell.execute_reply.started":"2023-10-25T00:30:40.109502Z","shell.execute_reply":"2023-10-25T00:30:40.131294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Switch sub(0.16 if True else scoring error)","metadata":{}},{"cell_type":"code","source":"if n_df == n_has_thumbnail:\n    print(\"* Clear sub\")\n    sub = pd.read_csv(df_path)\n    sub[\"label\"] = \"CC\"\n    sub = sub[[\"image_id\", \"label\"]]\n    sub.to_csv(\"submission.csv\", index=False)\n    display(sub.head())\nelse:\n    # make scoring error sub\n    print(\"* Error sub\")\n    sub_error = pd.read_csv(df_path)\n    sub_error[\"label\"] = -1\n    sub_error = sub_error[[\"image_id\", \"label\"]]\n    sub_error.to_csv(\"submission.csv\", index=False)\n    display(sub_error.head())","metadata":{"execution":{"iopub.status.busy":"2023-10-25T00:31:07.634689Z","iopub.execute_input":"2023-10-25T00:31:07.635196Z","iopub.status.idle":"2023-10-25T00:31:07.654412Z","shell.execute_reply.started":"2023-10-25T00:31:07.635168Z","shell.execute_reply":"2023-10-25T00:31:07.652453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}