{"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 pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport matplotlib.image as mpimg\nfrom matplotlib.offsetbox import AnnotationBbox, OffsetImage\n\nimport plotly.express as px\n\nimport descartes\nimport geopandas as gpd\nfrom shapely.geometry import Point, Polygon\n\nimport librosa\nimport librosa.display\nimport IPython.display as ipd\n\nimport sklearn\n\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2022-05-10T11:49:19.846722Z","iopub.execute_input":"2022-05-10T11:49:19.847045Z","iopub.status.idle":"2022-05-10T11:49:19.857963Z","shell.execute_reply.started":"2022-05-10T11:49:19.847011Z","shell.execute_reply":"2022-05-10T11:49:19.856893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_csv = pd.read_csv(\"../input/birdclef-2022/train_metadata.csv\")\ntest_csv = pd.read_csv(\"../input/birdclef-2022/test.csv\")\nprint(\"There are {:,} unique bird species in the dataset.\".format(len(train_csv['common_name'].unique())))","metadata":{"execution":{"iopub.status.busy":"2022-05-10T11:49:20.049614Z","iopub.execute_input":"2022-05-10T11:49:20.049912Z","iopub.status.idle":"2022-05-10T11:49:20.128933Z","shell.execute_reply.started":"2022-05-10T11:49:20.049879Z","shell.execute_reply":"2022-05-10T11:49:20.128201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_csv[['hour', 'minute']] = train_csv['time'].str.split(':', 1, expand=True)","metadata":{"execution":{"iopub.status.busy":"2022-05-10T11:49:20.246958Z","iopub.execute_input":"2022-05-10T11:49:20.247260Z","iopub.status.idle":"2022-05-10T11:49:20.280808Z","shell.execute_reply.started":"2022-05-10T11:49:20.247222Z","shell.execute_reply":"2022-05-10T11:49:20.279836Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16, 6))\nax = sns.countplot(train_csv['hour'], palette=\"hls\")\n\n\nplt.title(\"Audio Files Registration at specific times\", fontsize=16)\nplt.xticks(rotation=90, fontsize=13)\nplt.yticks(fontsize=13)\nplt.ylabel(\"Frequency\", fontsize=14)\nplt.xlabel(\"\");","metadata":{"execution":{"iopub.status.busy":"2022-05-10T11:49:20.436065Z","iopub.execute_input":"2022-05-10T11:49:20.436367Z","iopub.status.idle":"2022-05-10T11:49:21.226893Z","shell.execute_reply.started":"2022-05-10T11:49:20.436333Z","shell.execute_reply":"2022-05-10T11:49:21.226052Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16, 6))\nax = sns.countplot(train_csv['rating'], palette=\"hls\")\n\n\nplt.title(\"Audio Files Registration with regards to Ratings\", fontsize=16)\nplt.xticks(rotation=90, fontsize=13)\nplt.yticks(fontsize=13)\nplt.ylabel(\"Frequency\", fontsize=14)\nplt.xlabel(\"\");","metadata":{"execution":{"iopub.status.busy":"2022-05-10T11:49:21.228424Z","iopub.execute_input":"2022-05-10T11:49:21.228750Z","iopub.status.idle":"2022-05-10T11:49:21.502880Z","shell.execute_reply.started":"2022-05-10T11:49:21.228714Z","shell.execute_reply":"2022-05-10T11:49:21.501894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"adjusted_type = train_csv['type'].apply(lambda x: x[2:-2].split(\"', '\")).reset_index().explode(\"type\")\n\n# Strip of white spaces and convert to lower chars\nadjusted_type = adjusted_type['type'].apply(lambda x: x.strip().lower()).reset_index()\nadjusted_type['type'] = adjusted_type['type'].replace('calls', 'call')\n\n# Create Top 15 list with song types\ntop_15 = list(adjusted_type['type'].value_counts().head(15).reset_index()['index'])\ndata = adjusted_type[adjusted_type['type'].isin(top_15)]\n\n# === PLOT ===\n\nplt.figure(figsize=(16, 6))\nax = sns.countplot(data['type'], palette=\"hls\", order = data['type'].value_counts().index)\n\nplt.title(\"Top 15 Song Types\", fontsize=16)\nplt.ylabel(\"Frequency\", fontsize=14)\nplt.yticks(fontsize=13)\nplt.xticks(rotation=90, fontsize=13)\nplt.xlabel(\"\");","metadata":{"execution":{"iopub.status.busy":"2022-05-10T11:49:21.504281Z","iopub.execute_input":"2022-05-10T11:49:21.504522Z","iopub.status.idle":"2022-05-10T11:49:21.905414Z","shell.execute_reply.started":"2022-05-10T11:49:21.504493Z","shell.execute_reply":"2022-05-10T11:49:21.904586Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top20 = train_csv['primary_label'].value_counts()[:20].index.tolist()","metadata":{"execution":{"iopub.status.busy":"2022-05-10T11:49:21.907166Z","iopub.execute_input":"2022-05-10T11:49:21.907399Z","iopub.status.idle":"2022-05-10T11:49:21.915515Z","shell.execute_reply.started":"2022-05-10T11:49:21.907369Z","shell.execute_reply":"2022-05-10T11:49:21.914376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#plt.figure(figsize=(15, 9))\nworld_map = gpd.read_file(\"../input/world-shapefile/world_shapefile.shp\")\nworld_map.plot(figsize = (15,9))\nsns.scatterplot(\"longitude\", \"latitude\", \n                data=train_csv[train_csv['primary_label'].isin(top20)], hue=train_csv[train_csv['primary_label'].isin(top20)]['primary_label'], \n                palette=\"hls\", legend=\"full\")\nplt.ylabel(\"Latitude\", fontsize=14)\nplt.xlabel(\"Longitude\", fontsize=14)\nplt.legend() \nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-05-10T11:49:21.916999Z","iopub.execute_input":"2022-05-10T11:49:21.917323Z","iopub.status.idle":"2022-05-10T11:49:23.998443Z","shell.execute_reply.started":"2022-05-10T11:49:21.917289Z","shell.execute_reply":"2022-05-10T11:49:23.997585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Work in Progress","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}