{"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":"# BirdCLEF 2022\n\n### Description:\n\nIn this competition, you’ll use your machine learning skills to identify bird species by sound. Specifically, you'll develop a model that can process continuous audio data and then acoustically recognize the species. The best entries will be able to train reliable classifiers with limited training data.","metadata":{}},{"cell_type":"markdown","source":"![image info](https://telecoms.com/wp-content/blogs.dir/1/files/2018/03/Angry-Birds-770x285.jpg)","metadata":{}},{"cell_type":"code","source":"# Beat tracking example\nfrom __future__ import print_function\nimport librosa\nimport librosa.display\nfrom scipy.fft import fft, fftfreq\nfrom scipy.signal import blackman\n\n%matplotlib inline\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport mimetypes\nmimetypes.init()\nmimetypes.add_type('audio/ogg', '.ogg')\nimport IPython.display as ipd\nimport plotly.express as px\nimport pandas as pd\nimport numpy as np\nimport sklearn\nimport ast\nimport json\n\nsns.set_palette(\"Reds\")\n","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:13.249942Z","iopub.execute_input":"2022-03-22T00:50:13.250417Z","iopub.status.idle":"2022-03-22T00:50:13.265992Z","shell.execute_reply.started":"2022-03-22T00:50:13.250364Z","shell.execute_reply":"2022-03-22T00:50:13.265174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Table of Contents\n\n* [Load data](#section_1)\n* [Analysing Metadata](#section_2)\n    * [Primary label](#section_2_1)\n    * [Secundary label](#section_2_2)\n    * [Type](#section_2_3)\n    * [Coordinates](#section_2_4)\n    * [Rating](#section_2_5)\n    * [Time](#section_2_6)\n* [Bird Taxonomy](#section_3)\n\n* [Analysing audio files](#section_4)\n    * [Spectrogram](#section_4_1)\n    * [MFCC](#section_4_2)\n","metadata":{}},{"cell_type":"markdown","source":"\n\n### Load data <a class=\"anchor\" id=\"section_1\"></a>\n\n","metadata":{}},{"cell_type":"code","source":"FILE_PATH = \"../input/birdclef-2022/\"\ntrain_metadata_df = pd.read_csv(FILE_PATH + \"train_metadata.csv\")\ntest_df = pd.read_csv(FILE_PATH + \"test.csv\")\nsample_submission_df = pd.read_csv(FILE_PATH + \"sample_submission.csv\")\nbird_taxo_df = pd.read_csv(FILE_PATH + \"eBird_Taxonomy_v2021.csv\")\nwith open(FILE_PATH + \"scored_birds.json\") as f:\n    scored_birds = json.load(f)\n","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:13.267693Z","iopub.execute_input":"2022-03-22T00:50:13.268162Z","iopub.status.idle":"2022-03-22T00:50:13.491567Z","shell.execute_reply.started":"2022-03-22T00:50:13.268130Z","shell.execute_reply":"2022-03-22T00:50:13.490621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Analysing Metadata <a class=\"anchor\" id=\"section_2\"></a>\n\ntrain_metadata.csv - A wide range of metadata is provided for the training data. The most directly relevant fields are:\n\n- primary_label - a code for the bird species. You can review detailed information about the bird codes by appending the code to https://ebird.org/species/, such as https://ebird.org/species/amecro for the American Crow.\n- secondary_labels: Background species as annotated by the recordist. An empty list does not mean that no background birds are audible.\n- author - the eBird user who provided the recording.\n- filename: the associated audio file.\n- rating: Float value between 0.0 and 5.0 as an indicator of the quality rating on Xeno-canto and the number of background species, where 5.0 is the highest and 1.0 is the lowest. 0.0 means that this recording has no user rating yet.\n","metadata":{}},{"cell_type":"code","source":"train_metadata_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:13.492830Z","iopub.execute_input":"2022-03-22T00:50:13.493135Z","iopub.status.idle":"2022-03-22T00:50:13.521130Z","shell.execute_reply.started":"2022-03-22T00:50:13.493102Z","shell.execute_reply":"2022-03-22T00:50:13.520262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:13.523290Z","iopub.execute_input":"2022-03-22T00:50:13.523633Z","iopub.status.idle":"2022-03-22T00:50:13.529517Z","shell.execute_reply.started":"2022-03-22T00:50:13.523581Z","shell.execute_reply":"2022-03-22T00:50:13.528830Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:13.530662Z","iopub.execute_input":"2022-03-22T00:50:13.531083Z","iopub.status.idle":"2022-03-22T00:50:13.542235Z","shell.execute_reply.started":"2022-03-22T00:50:13.531046Z","shell.execute_reply":"2022-03-22T00:50:13.541637Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\n#### Primary label <a class=\"anchor\" id=\"section_2_1\"></a>\n\n\nFirst of all, we are going to analysis how many birds species we have abailabel in our dataset. As we can see, we have 152 different species.\n","metadata":{}},{"cell_type":"code","source":"train_metadata_df.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:13.543208Z","iopub.execute_input":"2022-03-22T00:50:13.544037Z","iopub.status.idle":"2022-03-22T00:50:13.578577Z","shell.execute_reply.started":"2022-03-22T00:50:13.544003Z","shell.execute_reply":"2022-03-22T00:50:13.578028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the graph bellow we can see that the majority species we have are `brnowl`, `skylar`, `norcar`, `mallar3` and so on. On the other hand, we have the species with the lowest number of audio register, such as `hawhaw`,`puaioh`, `bkwpet` and `maupar` that only have a few audio recods. That represent a challenge to train a classification model witch such amount of data. I think that a good idea to deal with such problem it is analysing the lenght of each record and split them in order to generate more file records for those species. we'll see..","metadata":{}},{"cell_type":"code","source":"sns.set_palette(\"Reds\")\n\ncount_birds_df = train_metadata_df.groupby('primary_label').agg(count_birds=('filename','count')).reset_index()\\\n    .sort_values('count_birds', ascending=False)\n\ntop_20_birds = count_birds_df.iloc[:20,:]\nbottom_20_birds = count_birds_df.sort_values('count_birds', ascending=True).iloc[:20,:]\n\nfig, ax =plt.subplots(1,2, figsize=(24,8))\nsns.barplot(x=\"count_birds\", y=\"primary_label\", orient='h', data=top_20_birds,ax=ax[0])\\\n        .set_title(\"Top 20 - Number bird species\")\n\nsns.barplot(x=\"count_birds\", y=\"primary_label\", orient='h', data=bottom_20_birds,ax=ax[1])\\\n        .set_title(\"Bottom 20 - Number bird species\")\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:13.579740Z","iopub.execute_input":"2022-03-22T00:50:13.580099Z","iopub.status.idle":"2022-03-22T00:50:14.350283Z","shell.execute_reply.started":"2022-03-22T00:50:13.580058Z","shell.execute_reply":"2022-03-22T00:50:14.349037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From scored birds, only `skylar` and `houfin` are present in the top 20 birds count,  on the contrary, `ercfra`, `hawhaw`, `hawpet1`, `maupar`, `crehon`, and `puaioh` on the bottom 20 birds.","metadata":{}},{"cell_type":"code","source":"print(set(top_20_birds.primary_label).intersection(scored_birds))\nprint(set(bottom_20_birds.primary_label).intersection(scored_birds))","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:14.351854Z","iopub.execute_input":"2022-03-22T00:50:14.352260Z","iopub.status.idle":"2022-03-22T00:50:14.360445Z","shell.execute_reply.started":"2022-03-22T00:50:14.352215Z","shell.execute_reply":"2022-03-22T00:50:14.359483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Let's see how many register we have for each scored birds. For most of them we only have less than 100 register. What it is worst, some bird's species has 1 register at the most.","metadata":{}},{"cell_type":"code","source":"sns.set_theme()\nscored_birds_count_df = count_birds_df[count_birds_df['primary_label'].isin(scored_birds)].sort_values('count_birds', ascending=False)\nplt.figure(figsize=(10,12))\nsns.barplot(x=\"count_birds\", y=\"primary_label\", orient='h', data=scored_birds_count_df).set_title(\"Number of bird species scored\")\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:14.362341Z","iopub.execute_input":"2022-03-22T00:50:14.362876Z","iopub.status.idle":"2022-03-22T00:50:14.752824Z","shell.execute_reply.started":"2022-03-22T00:50:14.362831Z","shell.execute_reply":"2022-03-22T00:50:14.751894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Secundary label <a class=\"anchor\" id=\"section_2_2\"></a>\n\nAs it is mentioned in the `train_metadata` 's description at the beginning, there are noises that come from the ambient and other bird species that make our classification problem more dificult. Those secundary species are identified in some register. Let's analize those cases in order to handle them propertly when we're going to train our model.\nThe total number of cases with this issues are 1478,  which represent nearly ten percent (9.95152168058174 %) of total cases. ","metadata":{}},{"cell_type":"code","source":"train_metadata_df['count_secondary_species'] = train_metadata_df['secondary_labels'].apply(lambda x : ast.literal_eval(x).__len__())\nprint(\"Num. total bird species with secondary species's noise in the audio reg: \", train_metadata_df[train_metadata_df['count_secondary_species']>0].primary_label.count())","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:14.756445Z","iopub.execute_input":"2022-03-22T00:50:14.756800Z","iopub.status.idle":"2022-03-22T00:50:14.847817Z","shell.execute_reply.started":"2022-03-22T00:50:14.756753Z","shell.execute_reply":"2022-03-22T00:50:14.846768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"`normoc`, `norcar`, `hawcre` and `hourspa` are some of the species that have more audio register with mixed species. Other bird species such as `hawcre`, `crehon`, `akiapo` and `oamo` have the higher mean of mixed species in every record that goes from 2 to 3.5.\n","metadata":{}},{"cell_type":"code","source":"sns.set_theme()\ncount_secespecies_df = train_metadata_df.groupby('primary_label').agg(count_secondary_species=('count_secondary_species','sum')).reset_index()\\\n    .sort_values('count_secondary_species', ascending=False)\n\nmen_secespecies_df = train_metadata_df.groupby('primary_label').agg(mean_secondary_species=('count_secondary_species','mean')).reset_index()\\\n    .sort_values('mean_secondary_species', ascending=False)\n\nmax_secespecies_df = train_metadata_df.groupby('primary_label').agg(max_secondary_species=('count_secondary_species','max')).reset_index()\\\n    .sort_values('max_secondary_species', ascending=False)\n\nfig, ax =plt.subplots(1,3, figsize=(20,18))\nsns.barplot(y=\"primary_label\", x=\"count_secondary_species\", orient='h',   data=count_secespecies_df[count_secespecies_df['count_secondary_species']>0],ax=ax[0])\\\n    .set_title(\"Num. secondary species's noise by primary bird species\")\n\nsns.barplot(y=\"primary_label\", x=\"mean_secondary_species\", orient='h',   data=men_secespecies_df[men_secespecies_df['mean_secondary_species']>0], ax=ax[1])\\\n    .set_title(\"Mean secondary species's noise by primary bird species\")\n\nsns.barplot(y=\"primary_label\", x=\"max_secondary_species\", orient='h',   data=max_secespecies_df[max_secespecies_df['max_secondary_species']>0], ax=ax[2])\\\n    .set_title(\"Max number secondary species's noise by primary bird species\")\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:14.849201Z","iopub.execute_input":"2022-03-22T00:50:14.849424Z","iopub.status.idle":"2022-03-22T00:50:20.403523Z","shell.execute_reply.started":"2022-03-22T00:50:14.849388Z","shell.execute_reply":"2022-03-22T00:50:20.402805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Type <a class=\"anchor\" id=\"section_2_3\"></a>\n\n\nThere are many types of  bird's sing registered (634), but only a few are significant, like `call`, `song`, `fight call`, `male` and so on. This information can be subjective, because relay on the knowldege and experience from each author. Also, it seems that it require a previous normalization work, because some registers like `call` show up as `calls`, `Call`, `begging call` and so on. <br />  However, it may will be a good idea to group them in each category to process the audio data or develop a model for each one (I am just thinking in loud..)","metadata":{}},{"cell_type":"code","source":"type_df = (train_metadata_df['type'].apply(lambda x: pd.Series(ast.literal_eval(x)))\n            .stack()\n            .reset_index(level=1, drop=True)\n            .to_frame('type')\n            .join(train_metadata_df[['primary_label']], how='left')\n            )\n\n\nsns.set_theme()\ncount_type_sing_df = type_df.groupby('type').agg(count_type_sing=('primary_label','count')).reset_index()\\\n    .sort_values('count_type_sing', ascending=False)\n\ntop_20_type_sing = count_type_sing_df.iloc[:20,:]\n\nplt.figure(figsize=(8,6))\n\nsns.barplot(x=\"count_type_sing\", y=\"type\", orient='h', data=top_20_type_sing)\\\n        .set_title(f\"Top 20 Type of bird songs -  Total type of bird songs: {type_df.type.nunique()}\")\n\n\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:20.404547Z","iopub.execute_input":"2022-03-22T00:50:20.405070Z","iopub.status.idle":"2022-03-22T00:50:24.088614Z","shell.execute_reply.started":"2022-03-22T00:50:20.405030Z","shell.execute_reply":"2022-03-22T00:50:24.087664Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"type_df = (train_metadata_df[train_metadata_df['primary_label'].isin(scored_birds)]['type'].apply(lambda x: pd.Series(ast.literal_eval(x)))\n            .stack()\n            .reset_index(level=1, drop=True)\n            .to_frame('type')\n            .join(train_metadata_df[train_metadata_df['primary_label'].isin(scored_birds)][['primary_label']], how='left')\n            )\n\n\nsns.set_theme()\ncount_type_sing_df = type_df.groupby('type').agg(count_type_sing=('primary_label','count')).reset_index()\\\n    .sort_values('count_type_sing', ascending=False)\n\ntop_20_type_sing = count_type_sing_df.iloc[:20,:]\n\nplt.figure(figsize=(8,6))\n\nsns.barplot(x=\"count_type_sing\", y=\"type\", orient='h', data=top_20_type_sing)\\\n        .set_title(f\"Top 20 Type of bird songs -  Total type of bird songs: {type_df.type.nunique()}\")\n\n","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:24.090348Z","iopub.execute_input":"2022-03-22T00:50:24.090982Z","iopub.status.idle":"2022-03-22T00:50:24.747746Z","shell.execute_reply.started":"2022-03-22T00:50:24.090941Z","shell.execute_reply":"2022-03-22T00:50:24.746724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Coordinates <a class=\"anchor\" id=\"section_2_4\"></a>\n\nHere there is not much to do, so let's plot every point in the map to have an idea about where most of audio register and birds species came from. ","metadata":{}},{"cell_type":"code","source":"train_metadata_df['bird_scored'] = np.where(train_metadata_df['primary_label'].isin(scored_birds), 'scored','noscored')\n\nfig = px.scatter_mapbox(train_metadata_df, lat=\"latitude\", lon=\"longitude\", hover_name=\"primary_label\", hover_data=[\"primary_label\", \"scientific_name\", \"common_name\", \"author\"],\n                        color=\"bird_scored\", zoom=3, height=300)\nfig.update_layout(mapbox_style=\"open-street-map\")\nfig.update_layout(margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0})\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:24.748942Z","iopub.execute_input":"2022-03-22T00:50:24.749170Z","iopub.status.idle":"2022-03-22T00:50:26.318458Z","shell.execute_reply.started":"2022-03-22T00:50:24.749143Z","shell.execute_reply":"2022-03-22T00:50:26.317782Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\n#### Rating <a class=\"anchor\" id=\"section_2_5\"></a>\n\nAs it is mentioned in the description, this indicator represent the quality of the audio (range from 0 to 5). <br>\nThe graph distribution below shows that  most audio register belong to bines 3 to 5. The boxplot shows the distribution between the top 20 birds, where we can see that each quality audio distribution is subtantially different. <br>","metadata":{}},{"cell_type":"code","source":"train_metadata_df.rating.describe()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:26.319463Z","iopub.execute_input":"2022-03-22T00:50:26.319903Z","iopub.status.idle":"2022-03-22T00:50:26.336297Z","shell.execute_reply.started":"2022-03-22T00:50:26.319865Z","shell.execute_reply":"2022-03-22T00:50:26.335119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set(style=\"ticks\")\n\n\nf, (ax_box, ax_hist) = plt.subplots(2, sharex=True, figsize=(10,10),\n                                    gridspec_kw={\"height_ratios\": (.15, .85)})\n\nsns.boxplot(train_metadata_df['rating'], ax=ax_box)\nsns.distplot(train_metadata_df['rating'], ax=ax_hist)\n\nax_box.set(yticks=[])\nsns.despine(ax=ax_hist)\nsns.despine(ax=ax_box, left=True)","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:26.338339Z","iopub.execute_input":"2022-03-22T00:50:26.339090Z","iopub.status.idle":"2022-03-22T00:50:26.803261Z","shell.execute_reply.started":"2022-03-22T00:50:26.339037Z","shell.execute_reply":"2022-03-22T00:50:26.802299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\n\nsns.boxplot(x=\"primary_label\", y=\"rating\",   data=train_metadata_df[train_metadata_df['primary_label'].isin(top_20_birds.primary_label.tolist())])\n","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:26.804682Z","iopub.execute_input":"2022-03-22T00:50:26.804950Z","iopub.status.idle":"2022-03-22T00:50:27.246226Z","shell.execute_reply.started":"2022-03-22T00:50:26.804922Z","shell.execute_reply":"2022-03-22T00:50:27.245502Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Let's see how is it look for the scored birds. Rating distribution looks so different for each birds species for these set.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\n\nsns.boxplot(x=\"primary_label\", y=\"rating\",   data=train_metadata_df[train_metadata_df['primary_label'].isin(scored_birds)]).set_title(\"Boxplot rating by scored birds\")\n","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:27.247359Z","iopub.execute_input":"2022-03-22T00:50:27.247848Z","iopub.status.idle":"2022-03-22T00:50:27.749115Z","shell.execute_reply.started":"2022-03-22T00:50:27.247809Z","shell.execute_reply":"2022-03-22T00:50:27.748084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Time <a class=\"anchor\" id=\"section_2_6\"></a>\n\nThis variable represent the lenght of each audio file. The variable is object type so firt we have to convert into a time value in order to analyze it. From the distribution graph we can see that it has a normal distribution (almost) as it is expected.\n","metadata":{}},{"cell_type":"code","source":"train_metadata_df.time.describe()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:27.750613Z","iopub.execute_input":"2022-03-22T00:50:27.751354Z","iopub.status.idle":"2022-03-22T00:50:27.762679Z","shell.execute_reply.started":"2022-03-22T00:50:27.751310Z","shell.execute_reply":"2022-03-22T00:50:27.761760Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df['time']  = train_metadata_df['time'].str.extract(r'(\\d{2}\\:\\d{2})') \n\ndef time2second(time):\n    if pd.isnull(time):\n        return None\n        \n    else:\n        return  float(time.split(':')[0])*60+float(time.split(':')[1])\n    \ntrain_metadata_df['time'] = train_metadata_df['time'].apply(lambda x: time2second(x) )\n\n#record_seconds = train_metadata_df[train_metadata_df.time.isnull()!=True].loc[:,'time', 'primary_label'].apply(lambda x: time2second(x[0]) )","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:27.764082Z","iopub.execute_input":"2022-03-22T00:50:27.764654Z","iopub.status.idle":"2022-03-22T00:50:27.816639Z","shell.execute_reply.started":"2022-03-22T00:50:27.764618Z","shell.execute_reply":"2022-03-22T00:50:27.815752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df['time'].describe()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:27.818261Z","iopub.execute_input":"2022-03-22T00:50:27.818762Z","iopub.status.idle":"2022-03-22T00:50:27.829121Z","shell.execute_reply.started":"2022-03-22T00:50:27.818717Z","shell.execute_reply":"2022-03-22T00:50:27.828243Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set(style=\"ticks\")\n\n\nf, (ax_box, ax_hist) = plt.subplots(2, sharex=True, figsize=(10,10),\n                                    gridspec_kw={\"height_ratios\": (.15, .85)})\n\nsns.boxplot(train_metadata_df['time'], ax=ax_box)\nsns.distplot(train_metadata_df['time'], ax=ax_hist)\n\nax_box.set(yticks=[])\nsns.despine(ax=ax_hist)\nsns.despine(ax=ax_box, left=True)","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:27.830222Z","iopub.execute_input":"2022-03-22T00:50:27.830797Z","iopub.status.idle":"2022-03-22T00:50:28.322426Z","shell.execute_reply.started":"2022-03-22T00:50:27.830759Z","shell.execute_reply":"2022-03-22T00:50:28.321717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the next boxplot graph , we can see that audio length has different distribution for each species.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\n\nsns.boxplot(x=\"primary_label\", y=\"time\",   data=train_metadata_df[train_metadata_df['primary_label'].isin(top_20_birds.primary_label.tolist())]).set_title(\"Boxplot time by top 20 bird species\")\n","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:28.323636Z","iopub.execute_input":"2022-03-22T00:50:28.324403Z","iopub.status.idle":"2022-03-22T00:50:28.841910Z","shell.execute_reply.started":"2022-03-22T00:50:28.324357Z","shell.execute_reply":"2022-03-22T00:50:28.840974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Time's distribution looks pretty different from scored bird set.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(16,8))\n\nsns.boxplot(x=\"primary_label\", y=\"time\",   data=train_metadata_df[train_metadata_df['primary_label'].isin(scored_birds)]).set_title(\"Boxplot time by scored bird species\")\n","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:28.843659Z","iopub.execute_input":"2022-03-22T00:50:28.844290Z","iopub.status.idle":"2022-03-22T00:50:29.383772Z","shell.execute_reply.started":"2022-03-22T00:50:28.844241Z","shell.execute_reply":"2022-03-22T00:50:29.382958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_metadata_df.iloc[0]","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:29.384817Z","iopub.execute_input":"2022-03-22T00:50:29.385068Z","iopub.status.idle":"2022-03-22T00:50:29.393235Z","shell.execute_reply.started":"2022-03-22T00:50:29.385037Z","shell.execute_reply":"2022-03-22T00:50:29.392172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Bird Taxo <a class=\"anchor\" id=\"section_3\"></a>\n\nBird_taxo provide a taxonomic categorization of each bird. Let's see which family belong each species of bird from scored group.","metadata":{}},{"cell_type":"code","source":"bird_taxo_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:29.394844Z","iopub.execute_input":"2022-03-22T00:50:29.395210Z","iopub.status.idle":"2022-03-22T00:50:29.413990Z","shell.execute_reply.started":"2022-03-22T00:50:29.395166Z","shell.execute_reply":"2022-03-22T00:50:29.413277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bird_taxo_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:29.415351Z","iopub.execute_input":"2022-03-22T00:50:29.415880Z","iopub.status.idle":"2022-03-22T00:50:29.426682Z","shell.execute_reply.started":"2022-03-22T00:50:29.415844Z","shell.execute_reply":"2022-03-22T00:50:29.425544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ntaxo_df = train_metadata_df[train_metadata_df['primary_label'].isin(scored_birds)].merge( bird_taxo_df, left_on='primary_label', right_on='SPECIES_CODE', how='inner')\nfig = px.parallel_categories(taxo_df[['primary_label', 'SPECIES_GROUP', 'ORDER1','FAMILY']])\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:29.432613Z","iopub.execute_input":"2022-03-22T00:50:29.433932Z","iopub.status.idle":"2022-03-22T00:50:29.527052Z","shell.execute_reply.started":"2022-03-22T00:50:29.433876Z","shell.execute_reply":"2022-03-22T00:50:29.526199Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Analysing audio files  <a class=\"anchor\" id=\"section_4\"></a>\n\nHere we are going to analize each audio file from scored bird group. For each sample we plot the raw audio file , spectrogram and MFCC. ","metadata":{}},{"cell_type":"code","source":"def plot_signal_info(signal, Fs, text=''):\n    \"\"\"1. Prints information about an audio singal, 2. plots the waveform, and 3. Creates player\n    \n    Args: \n        x: Input signal\n        Fs: Sampling rate of x    \n        text: Text to print\n    \"\"\"\n    print('%s Fs = %d, x.shape = %s, x.dtype = %s' % (text, Fs, signal.shape, signal.dtype))\n    fig, axs = plt.subplots(2, 2, figsize=(24, 12))\n\n    N = len(signal)\n\n\n    time = np.arange(0,N / Fs,1/Fs)\n\n    # plot raw signal\n    axs[0, 0].plot(time, signal, color='royalblue')\n    axs[0, 0].set_xlabel('Time (Seg)')\n    axs[0, 0].set_ylabel('Amplitude')\n    axs[0, 0].set_title('Raw signal')\n\n\n    # plot fourier\n    w = blackman(N)\n    ywf = fft(signal*w)\n    xf = fftfreq(N, 1/Fs)[:N//2]\n\n    axs[1, 0].semilogy(xf[1:N//2], 2.0/N * np.abs(ywf[1:N//2]), '-r')\n    axs[1, 0].set_xlabel('Frequency (Hz)')\n    axs[1, 0].set_ylabel('Log')\n    axs[1, 0].set_title('Fourier Transform (FFT')\n\n\n    # plot Power spectrogram\n    Y = librosa.stft(signal,  n_fft=512, win_length=512,hop_length=220 )\n    Ydb = librosa.amplitude_to_db(abs(Y), ref=np.max)\n    img = librosa.display.specshow(Ydb, y_axis='log',  sr=Fs, x_axis='time',  ax=axs[0, 1])\n    fig.colorbar(img, ax=axs[0, 1], format='%+2.0f dB')\n    axs[0, 1].set_title('Power spectrogram (STFT)')\n    axs[0, 1].set_xlabel('Time (Seg)')\n\n\n    # plot Mel Spectogram (1 ~ 14)\n    S = librosa.feature.melspectrogram(y=signal, sr=Fs, n_mels=128,\n                                   fmax=Fs/2)\n    img = librosa.display.specshow(librosa.power_to_db(S[1:14,:], ref=np.max), y_axis='mel', sr=Fs, x_axis='time', ax=axs[1, 1])\n\n    fig.colorbar(img, ax=axs[1, 1], format='%+2.0f dB')\n    axs[1, 1].set_title('Mel spectrogram')\n    axs[1, 1].set_xlabel('Time (Seg)')\n\n\n    #axs[0, 0].tight_layout()\n    plt.show()\n    ipd.display(ipd.Audio(data=signal, rate=Fs))","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:29.528245Z","iopub.execute_input":"2022-03-22T00:50:29.529147Z","iopub.status.idle":"2022-03-22T00:50:29.542189Z","shell.execute_reply.started":"2022-03-22T00:50:29.529108Z","shell.execute_reply":"2022-03-22T00:50:29.541147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def load_sound_file(filename):\n  \n    fpath = FILE_PATH + 'train_audio/' + filename\n    return librosa.load(fpath)","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:29.543448Z","iopub.execute_input":"2022-03-22T00:50:29.544135Z","iopub.status.idle":"2022-03-22T00:50:29.556592Z","shell.execute_reply.started":"2022-03-22T00:50:29.544081Z","shell.execute_reply":"2022-03-22T00:50:29.555758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### akiapo","metadata":{}},{"cell_type":"code","source":"idx = 0 \nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:29.558138Z","iopub.execute_input":"2022-03-22T00:50:29.558431Z","iopub.status.idle":"2022-03-22T00:50:39.163075Z","shell.execute_reply.started":"2022-03-22T00:50:29.558392Z","shell.execute_reply":"2022-03-22T00:50:39.161758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### aniani","metadata":{}},{"cell_type":"code","source":"idx = 1\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:39.164441Z","iopub.execute_input":"2022-03-22T00:50:39.164690Z","iopub.status.idle":"2022-03-22T00:50:42.221087Z","shell.execute_reply.started":"2022-03-22T00:50:39.164660Z","shell.execute_reply":"2022-03-22T00:50:42.219877Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### apapan","metadata":{}},{"cell_type":"code","source":"idx = 2\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:42.222378Z","iopub.execute_input":"2022-03-22T00:50:42.222626Z","iopub.status.idle":"2022-03-22T00:50:54.037141Z","shell.execute_reply.started":"2022-03-22T00:50:42.222597Z","shell.execute_reply":"2022-03-22T00:50:54.035812Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### barpet","metadata":{}},{"cell_type":"code","source":"idx = 3\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:50:54.039079Z","iopub.execute_input":"2022-03-22T00:50:54.039347Z","iopub.status.idle":"2022-03-22T00:51:10.029973Z","shell.execute_reply.started":"2022-03-22T00:50:54.039317Z","shell.execute_reply":"2022-03-22T00:51:10.028918Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### crehon","metadata":{}},{"cell_type":"code","source":"idx = 4\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:10.031752Z","iopub.execute_input":"2022-03-22T00:51:10.032080Z","iopub.status.idle":"2022-03-22T00:51:12.593682Z","shell.execute_reply.started":"2022-03-22T00:51:10.032045Z","shell.execute_reply":"2022-03-22T00:51:12.592793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### elepai","metadata":{}},{"cell_type":"code","source":"idx = 5\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:12.594769Z","iopub.execute_input":"2022-03-22T00:51:12.595290Z","iopub.status.idle":"2022-03-22T00:51:15.213771Z","shell.execute_reply.started":"2022-03-22T00:51:12.595256Z","shell.execute_reply":"2022-03-22T00:51:15.212810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### ercfra","metadata":{}},{"cell_type":"code","source":"idx = 6\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:15.215233Z","iopub.execute_input":"2022-03-22T00:51:15.215609Z","iopub.status.idle":"2022-03-22T00:51:16.630094Z","shell.execute_reply.started":"2022-03-22T00:51:15.215567Z","shell.execute_reply":"2022-03-22T00:51:16.629501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### hawama","metadata":{}},{"cell_type":"code","source":"idx = 7\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:16.631231Z","iopub.execute_input":"2022-03-22T00:51:16.631600Z","iopub.status.idle":"2022-03-22T00:51:23.378846Z","shell.execute_reply.started":"2022-03-22T00:51:16.631548Z","shell.execute_reply":"2022-03-22T00:51:23.377779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### hawcre","metadata":{}},{"cell_type":"code","source":"idx = 8\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:23.380622Z","iopub.execute_input":"2022-03-22T00:51:23.381175Z","iopub.status.idle":"2022-03-22T00:51:45.757464Z","shell.execute_reply.started":"2022-03-22T00:51:23.381128Z","shell.execute_reply":"2022-03-22T00:51:45.754959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### hawgoo","metadata":{}},{"cell_type":"code","source":"idx = 9\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:45.759310Z","iopub.execute_input":"2022-03-22T00:51:45.759622Z","iopub.status.idle":"2022-03-22T00:51:48.016850Z","shell.execute_reply.started":"2022-03-22T00:51:45.759588Z","shell.execute_reply":"2022-03-22T00:51:48.015676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### hawhaw","metadata":{}},{"cell_type":"code","source":"idx = 10\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:48.018333Z","iopub.execute_input":"2022-03-22T00:51:48.018778Z","iopub.status.idle":"2022-03-22T00:51:49.764465Z","shell.execute_reply.started":"2022-03-22T00:51:48.018685Z","shell.execute_reply":"2022-03-22T00:51:49.763600Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### hawpet1","metadata":{}},{"cell_type":"code","source":"idx = 11\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:49.765805Z","iopub.execute_input":"2022-03-22T00:51:49.766425Z","iopub.status.idle":"2022-03-22T00:51:58.550178Z","shell.execute_reply.started":"2022-03-22T00:51:49.766377Z","shell.execute_reply":"2022-03-22T00:51:58.549205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### houfin","metadata":{}},{"cell_type":"code","source":"idx = 12\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:51:58.551848Z","iopub.execute_input":"2022-03-22T00:51:58.552319Z","iopub.status.idle":"2022-03-22T00:52:02.375294Z","shell.execute_reply.started":"2022-03-22T00:51:58.552272Z","shell.execute_reply":"2022-03-22T00:52:02.374035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### iiwi","metadata":{}},{"cell_type":"code","source":"idx = 13\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:52:02.376580Z","iopub.execute_input":"2022-03-22T00:52:02.377125Z","iopub.status.idle":"2022-03-22T00:52:05.591988Z","shell.execute_reply.started":"2022-03-22T00:52:02.377086Z","shell.execute_reply":"2022-03-22T00:52:05.591067Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### jabwar","metadata":{}},{"cell_type":"code","source":"idx = 14\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:52:05.593113Z","iopub.execute_input":"2022-03-22T00:52:05.593338Z","iopub.status.idle":"2022-03-22T00:52:08.131526Z","shell.execute_reply.started":"2022-03-22T00:52:05.593310Z","shell.execute_reply":"2022-03-22T00:52:08.130570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### maupar","metadata":{}},{"cell_type":"code","source":"idx = 15\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:52:08.132907Z","iopub.execute_input":"2022-03-22T00:52:08.133781Z","iopub.status.idle":"2022-03-22T00:52:27.709047Z","shell.execute_reply.started":"2022-03-22T00:52:08.133733Z","shell.execute_reply":"2022-03-22T00:52:27.707947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### omao","metadata":{}},{"cell_type":"code","source":"idx = 16\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:52:27.710689Z","iopub.execute_input":"2022-03-22T00:52:27.711066Z","iopub.status.idle":"2022-03-22T00:52:42.155890Z","shell.execute_reply.started":"2022-03-22T00:52:27.711021Z","shell.execute_reply":"2022-03-22T00:52:42.155192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### puaioh","metadata":{}},{"cell_type":"code","source":"idx = 17\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:52:42.156863Z","iopub.execute_input":"2022-03-22T00:52:42.157216Z","iopub.status.idle":"2022-03-22T00:52:44.158305Z","shell.execute_reply.started":"2022-03-22T00:52:42.157187Z","shell.execute_reply":"2022-03-22T00:52:44.157398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### skylar","metadata":{}},{"cell_type":"code","source":"idx = 18\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:52:44.159498Z","iopub.execute_input":"2022-03-22T00:52:44.159777Z","iopub.status.idle":"2022-03-22T00:52:47.114743Z","shell.execute_reply.started":"2022-03-22T00:52:44.159742Z","shell.execute_reply":"2022-03-22T00:52:47.113760Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### warwhe1","metadata":{}},{"cell_type":"code","source":"idx = 20\nbird_sample = train_metadata_df[train_metadata_df['primary_label']==scored_birds[idx]].sample(1)\nsound_file_path = bird_sample['filename'].values[0]\nsignal, fs = load_sound_file(sound_file_path)\nbird_name = scored_birds[idx]\nplot_signal_info(signal=signal, Fs=fs, text=f'{bird_name} ({sound_file_path}) : ')","metadata":{"execution":{"iopub.status.busy":"2022-03-22T00:52:47.115912Z","iopub.execute_input":"2022-03-22T00:52:47.116165Z","iopub.status.idle":"2022-03-22T00:52:51.069801Z","shell.execute_reply.started":"2022-03-22T00:52:47.116135Z","shell.execute_reply":"2022-03-22T00:52:51.068713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}