{"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":"none","dataSources":[{"sourceId":70203,"databundleVersionId":8068726,"sourceType":"competition"},{"sourceId":8041358,"sourceType":"datasetVersion","datasetId":4740976},{"sourceId":170575100,"sourceType":"kernelVersion"}],"dockerImageVersionId":30684,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\n\npd.options.display.max_rows = 200","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-04-09T06:07:04.078115Z","iopub.execute_input":"2024-04-09T06:07:04.078645Z","iopub.status.idle":"2024-04-09T06:07:04.084551Z","shell.execute_reply.started":"2024-04-09T06:07:04.078593Z","shell.execute_reply":"2024-04-09T06:07:04.083358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meta_df = pd.read_csv(\"/kaggle/input/birdclef2024-metadata-dataframe/metadata.csv\",index_col=0)\nmaster_df = pd.read_csv(\"/kaggle/input/birdclef-2024/eBird_Taxonomy_v2021.csv\")\nspc2sci = master_df[[\"SPECIES_CODE\",\"SCI_NAME\"]].set_index(\"SCI_NAME\")[\"SPECIES_CODE\"].to_dict()\nmeta_df[\"SCI_NAME\"] = meta_df[\"gen\"] + \" \" + meta_df[\"sp\"]\nmeta_df = pd.merge(meta_df, master_df[[\"SPECIES_CODE\",\"SCI_NAME\"]], on=[\"SCI_NAME\"])\nmeta_df[\"secondary_labels\"] = meta_df.also.apply(eval).apply(lambda x: [spc2sci[t] for t in x if t in spc2sci.keys()])\nsubmit_label = set(\n    pd.read_csv(\"/kaggle/input/birdclef-2024/sample_submission.csv\").columns[1:]\n)\nmeta_df = meta_df[meta_df[\"SPECIES_CODE\"].isin(submit_label)].reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2024-04-09T05:54:52.557687Z","iopub.execute_input":"2024-04-09T05:54:52.558076Z","iopub.status.idle":"2024-04-09T05:55:02.729762Z","shell.execute_reply.started":"2024-04-09T05:54:52.558046Z","shell.execute_reply":"2024-04-09T05:55:02.728643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv(\"/kaggle/input/birdclef-2024/train_metadata.csv\")\ntrain_df[\"id\"] = train_df[\"filename\"].apply(\n    lambda x: int(x.split(\"/\")[-1].replace(\"XC\",\"\").replace(\".ogg\",\"\"))\n)\nretrival_candidates = meta_df[~meta_df.id.isin(train_df.id.values)].reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2024-04-09T06:01:34.397547Z","iopub.execute_input":"2024-04-09T06:01:34.398031Z","iopub.status.idle":"2024-04-09T06:01:34.599132Z","shell.execute_reply.started":"2024-04-09T06:01:34.397995Z","shell.execute_reply":"2024-04-09T06:01:34.597966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"retrival_candidates[\"SPECIES_CODE\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-04-09T06:07:05.493972Z","iopub.execute_input":"2024-04-09T06:07:05.494383Z","iopub.status.idle":"2024-04-09T06:07:05.510137Z","shell.execute_reply.started":"2024-04-09T06:07:05.494337Z","shell.execute_reply":"2024-04-09T06:07:05.508863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2024-04-09T06:06:02.160636Z","iopub.execute_input":"2024-04-09T06:06:02.161010Z","iopub.status.idle":"2024-04-09T06:06:02.187693Z","shell.execute_reply.started":"2024-04-09T06:06:02.160984Z","shell.execute_reply":"2024-04-09T06:06:02.186477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2024-04-09T05:54:39.366440Z","iopub.execute_input":"2024-04-09T05:54:39.366873Z","iopub.status.idle":"2024-04-09T05:54:39.488944Z","shell.execute_reply.started":"2024-04-09T05:54:39.366841Z","shell.execute_reply":"2024-04-09T05:54:39.487506Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2024-04-09T05:41:14.766463Z","iopub.execute_input":"2024-04-09T05:41:14.766885Z","iopub.status.idle":"2024-04-09T05:41:14.803231Z","shell.execute_reply.started":"2024-04-09T05:41:14.766851Z","shell.execute_reply":"2024-04-09T05:41:14.802158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2024-04-09T05:44:25.255861Z","iopub.execute_input":"2024-04-09T05:44:25.256913Z","iopub.status.idle":"2024-04-09T05:44:30.269144Z","shell.execute_reply.started":"2024-04-09T05:44:25.256865Z","shell.execute_reply":"2024-04-09T05:44:30.268299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2024-04-09T05:38:17.032164Z","iopub.execute_input":"2024-04-09T05:38:17.032602Z","iopub.status.idle":"2024-04-09T05:38:17.613636Z","shell.execute_reply.started":"2024-04-09T05:38:17.032571Z","shell.execute_reply":"2024-04-09T05:38:17.612394Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}