{"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 os\n\nimport cv2\nimport folium\nimport pandas as pd\nimport numpy as np\nimport plotly.express as px\nimport matplotlib.pyplot as plt\nfrom folium.plugins import HeatMap","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:07.021290Z","iopub.execute_input":"2023-03-08T05:12:07.022179Z","iopub.status.idle":"2023-03-08T05:12:10.643802Z","shell.execute_reply.started":"2023-03-08T05:12:07.022139Z","shell.execute_reply":"2023-03-08T05:12:10.641953Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(os.listdir(\"/kaggle/input/birdclef-2023/train_audio\"))","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:10.646067Z","iopub.execute_input":"2023-03-08T05:12:10.646454Z","iopub.status.idle":"2023-03-08T05:12:10.697912Z","shell.execute_reply.started":"2023-03-08T05:12:10.646417Z","shell.execute_reply":"2023-03-08T05:12:10.696594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls /kaggle/input/birdclef-2023/test_soundscapes","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:10.699317Z","iopub.execute_input":"2023-03-08T05:12:10.699750Z","iopub.status.idle":"2023-03-08T05:12:10.977167Z","shell.execute_reply.started":"2023-03-08T05:12:10.699708Z","shell.execute_reply":"2023-03-08T05:12:10.975429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls -lh /kaggle/input/birdclef-2023/test_soundscapes/soundscape_29201.ogg","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:10.980107Z","iopub.execute_input":"2023-03-08T05:12:10.980771Z","iopub.status.idle":"2023-03-08T05:12:11.266447Z","shell.execute_reply.started":"2023-03-08T05:12:10.980731Z","shell.execute_reply":"2023-03-08T05:12:11.264844Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df = pd.read_csv(\"/kaggle/input/birdclef-2023/train_metadata.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:11.268842Z","iopub.execute_input":"2023-03-08T05:12:11.269353Z","iopub.status.idle":"2023-03-08T05:12:11.407195Z","shell.execute_reply.started":"2023-03-08T05:12:11.269301Z","shell.execute_reply":"2023-03-08T05:12:11.405425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:11.409369Z","iopub.execute_input":"2023-03-08T05:12:11.409795Z","iopub.status.idle":"2023-03-08T05:12:11.446250Z","shell.execute_reply.started":"2023-03-08T05:12:11.409760Z","shell.execute_reply":"2023-03-08T05:12:11.445181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Examples count:\", len(train_metadata_df))","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:11.447646Z","iopub.execute_input":"2023-03-08T05:12:11.447979Z","iopub.status.idle":"2023-03-08T05:12:11.455239Z","shell.execute_reply.started":"2023-03-08T05:12:11.447942Z","shell.execute_reply":"2023-03-08T05:12:11.453578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df.describe()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:11.457043Z","iopub.execute_input":"2023-03-08T05:12:11.457499Z","iopub.status.idle":"2023-03-08T05:12:11.498379Z","shell.execute_reply.started":"2023-03-08T05:12:11.457429Z","shell.execute_reply":"2023-03-08T05:12:11.496982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:11.499997Z","iopub.execute_input":"2023-03-08T05:12:11.500662Z","iopub.status.idle":"2023-03-08T05:12:11.517621Z","shell.execute_reply.started":"2023-03-08T05:12:11.500615Z","shell.execute_reply":"2023-03-08T05:12:11.516331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"primary_label_counts = train_metadata_df.primary_label.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:11.522308Z","iopub.execute_input":"2023-03-08T05:12:11.522818Z","iopub.status.idle":"2023-03-08T05:12:11.531388Z","shell.execute_reply.started":"2023-03-08T05:12:11.522782Z","shell.execute_reply":"2023-03-08T05:12:11.530224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Primary labels count:\", len(primary_label_counts.index))","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:11.533018Z","iopub.execute_input":"2023-03-08T05:12:11.533409Z","iopub.status.idle":"2023-03-08T05:12:11.543685Z","shell.execute_reply.started":"2023-03-08T05:12:11.533367Z","shell.execute_reply":"2023-03-08T05:12:11.542385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"primary_label_counts = train_metadata_df.primary_label.value_counts()\n\nfig = px.bar(x=primary_label_counts.index, y=primary_label_counts.values)\nfig.update_layout(xaxis_title=\"Label\", yaxis_title=\"Count\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:11.545335Z","iopub.execute_input":"2023-03-08T05:12:11.545654Z","iopub.status.idle":"2023-03-08T05:12:13.358566Z","shell.execute_reply.started":"2023-03-08T05:12:11.545622Z","shell.execute_reply":"2023-03-08T05:12:13.357537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"All secondary column occurrences:\", sum(train_metadata_df.secondary_labels != \"[]\"))","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:13.360119Z","iopub.execute_input":"2023-03-08T05:12:13.360546Z","iopub.status.idle":"2023-03-08T05:12:13.370375Z","shell.execute_reply.started":"2023-03-08T05:12:13.360512Z","shell.execute_reply":"2023-03-08T05:12:13.369545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"all_secondary_labels = sum([eval(x) for x in train_metadata_df.secondary_labels], [])\nall_secondary_labels_counts = pd.value_counts(all_secondary_labels)","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:13.372267Z","iopub.execute_input":"2023-03-08T05:12:13.372666Z","iopub.status.idle":"2023-03-08T05:12:13.628234Z","shell.execute_reply.started":"2023-03-08T05:12:13.372624Z","shell.execute_reply":"2023-03-08T05:12:13.627177Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.bar(x=all_secondary_labels_counts.index, y=all_secondary_labels_counts.values)\nfig.update_layout(xaxis_title=\"Secondary Label\", yaxis_title=\"Count\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:13.629652Z","iopub.execute_input":"2023-03-08T05:12:13.629934Z","iopub.status.idle":"2023-03-08T05:12:13.685027Z","shell.execute_reply.started":"2023-03-08T05:12:13.629907Z","shell.execute_reply":"2023-03-08T05:12:13.683526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Type column occurrences:\", sum(train_metadata_df.type != \"[]\"))","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:13.686277Z","iopub.execute_input":"2023-03-08T05:12:13.686865Z","iopub.status.idle":"2023-03-08T05:12:13.695429Z","shell.execute_reply.started":"2023-03-08T05:12:13.686834Z","shell.execute_reply":"2023-03-08T05:12:13.694065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"type_labels = sum([eval(x) for x in train_metadata_df.type], [])\ntype_counts = pd.value_counts(type_labels)","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:13.696978Z","iopub.execute_input":"2023-03-08T05:12:13.697269Z","iopub.status.idle":"2023-03-08T05:12:15.105416Z","shell.execute_reply.started":"2023-03-08T05:12:13.697241Z","shell.execute_reply":"2023-03-08T05:12:15.103738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.bar(x=type_counts.index, y=type_counts.values)\nfig.update_layout(xaxis_title=\"Audio type\", yaxis_title=\"Count\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:15.107318Z","iopub.execute_input":"2023-03-08T05:12:15.107682Z","iopub.status.idle":"2023-03-08T05:12:15.167654Z","shell.execute_reply.started":"2023-03-08T05:12:15.107646Z","shell.execute_reply":"2023-03-08T05:12:15.166820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"scientific_name_counts = train_metadata_df.scientific_name.value_counts()\n\nfig = px.bar(x=scientific_name_counts.index, y=scientific_name_counts.values)\nfig.update_layout(xaxis_title=\"Scientific name\", yaxis_title=\"Count\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:15.169052Z","iopub.execute_input":"2023-03-08T05:12:15.169333Z","iopub.status.idle":"2023-03-08T05:12:15.229680Z","shell.execute_reply.started":"2023-03-08T05:12:15.169303Z","shell.execute_reply":"2023-03-08T05:12:15.228191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# As we considired before we have some NaN values in the data, let's drop it\nfiltered_train_metadata_df = train_metadata_df.dropna()\n\n# Create a folium map object centered on the mean of the latitude and longitude coordinates\nmap_center = [\n    filtered_train_metadata_df.latitude.mean(), \n    filtered_train_metadata_df.longitude.mean()\n]\nm = folium.Map(location=map_center, zoom_start=4)\n\n# Create a heatmap layer using the latitude and longitude coordinates\nheat_data = filtered_train_metadata_df[['latitude', 'longitude']].values.tolist()\nHeatMap(heat_data).add_to(m)\n\n# And visualize\nm","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:15.231712Z","iopub.execute_input":"2023-03-08T05:12:15.232030Z","iopub.status.idle":"2023-03-08T05:12:15.412234Z","shell.execute_reply.started":"2023-03-08T05:12:15.231998Z","shell.execute_reply":"2023-03-08T05:12:15.410851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ebt_df = pd.read_csv(\"/kaggle/input/birdclef-2023/eBird_Taxonomy_v2021.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:15.413884Z","iopub.execute_input":"2023-03-08T05:12:15.414206Z","iopub.status.idle":"2023-03-08T05:12:15.491853Z","shell.execute_reply.started":"2023-03-08T05:12:15.414173Z","shell.execute_reply":"2023-03-08T05:12:15.490180Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ebt_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:15.493382Z","iopub.execute_input":"2023-03-08T05:12:15.493844Z","iopub.status.idle":"2023-03-08T05:12:15.509277Z","shell.execute_reply.started":"2023-03-08T05:12:15.493801Z","shell.execute_reply":"2023-03-08T05:12:15.508531Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(ebt_df)","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:15.510555Z","iopub.execute_input":"2023-03-08T05:12:15.511018Z","iopub.status.idle":"2023-03-08T05:12:15.523277Z","shell.execute_reply.started":"2023-03-08T05:12:15.510975Z","shell.execute_reply":"2023-03-08T05:12:15.521983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ebt_df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-08T05:12:15.524360Z","iopub.execute_input":"2023-03-08T05:12:15.524732Z","iopub.status.idle":"2023-03-08T05:12:15.542604Z","shell.execute_reply.started":"2023-03-08T05:12:15.524696Z","shell.execute_reply":"2023-03-08T05:12:15.541287Z"},"trusted":true},"execution_count":null,"outputs":[]}]}