{"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":"\n<div style = \"height: 50px;\n  width: 800px;\n  background-color: #813EEC;\">\n    <h1 style=\"padding: 10px;\n              color:white;\">\n    <b>1. Improting Libraries</b>\n    </h1>\n\n</div>","metadata":{}},{"cell_type":"code","source":"import ast\nimport librosa\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport plotly.express as px\nimport plotly.graph_objs as go\nfrom collections import Counter\nimport matplotlib.pyplot as plt\nimport torchaudio\nfrom IPython.display import Audio","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:30.018882Z","iopub.execute_input":"2023-03-29T07:29:30.019345Z","iopub.status.idle":"2023-03-29T07:29:30.027257Z","shell.execute_reply.started":"2023-03-29T07:29:30.019308Z","shell.execute_reply":"2023-03-29T07:29:30.025828Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\n<div style = \"height: 50px;\n  width: 800px;\n  background-color: #813EEC;\">\n    <h1 style=\"padding: 10px;\n              color:white;\">\n    <b>2. Reading Data</b>\n    </h1>\n\n</div>","metadata":{}},{"cell_type":"code","source":"train_meta_data = pd.read_csv(\"/kaggle/input/birdclef-2023/train_metadata.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:30.087810Z","iopub.execute_input":"2023-03-29T07:29:30.089005Z","iopub.status.idle":"2023-03-29T07:29:30.174750Z","shell.execute_reply.started":"2023-03-29T07:29:30.088955Z","shell.execute_reply":"2023-03-29T07:29:30.173503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_meta_data.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:30.176975Z","iopub.execute_input":"2023-03-29T07:29:30.177404Z","iopub.status.idle":"2023-03-29T07:29:30.197184Z","shell.execute_reply.started":"2023-03-29T07:29:30.177366Z","shell.execute_reply":"2023-03-29T07:29:30.195898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"abethrl = \"/kaggle/input/birdclef-2023/train_audio/abethr1/XC128013.ogg\"","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:30.198626Z","iopub.execute_input":"2023-03-29T07:29:30.198993Z","iopub.status.idle":"2023-03-29T07:29:30.210194Z","shell.execute_reply.started":"2023-03-29T07:29:30.198955Z","shell.execute_reply":"2023-03-29T07:29:30.208503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\n<div style = \"height: 50px;\n  width: 800px;\n  background-color: #813EEC;\">\n    <h1 style=\"padding: 10px;\n              color:white;\">\n        <b>2. EDA</b>\n    </h1>\n\n</div>","metadata":{}},{"cell_type":"code","source":"import librosa.display\nimport librosa\n\naudio_signal, sr = librosa.load(abethrl,sr=22050)\nlibrosa.display.waveshow(audio_signal, sr=sr)\nplt.xlabel(\"Time\")\nplt.ylabel(\"Amplitude\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:30.213393Z","iopub.execute_input":"2023-03-29T07:29:30.214254Z","iopub.status.idle":"2023-03-29T07:29:30.668630Z","shell.execute_reply.started":"2023-03-29T07:29:30.214207Z","shell.execute_reply":"2023-03-29T07:29:30.667252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#  frequency information about the signal.\nfft_spectrum = np.fft.fft(audio_signal)\n\nmagnitude_spectrum = np.abs(fft_spectrum)\n\nsample_rate = 44100  \nfrequency_axis = np.linspace(0, sample_rate, len(magnitude_spectrum))\n\nimport matplotlib.pyplot as plt\nplt.plot(frequency_axis, magnitude_spectrum)\nplt.xlabel('Frequency (Hz)')\nplt.ylabel('Magnitude')\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:30.670274Z","iopub.execute_input":"2023-03-29T07:29:30.670784Z","iopub.status.idle":"2023-03-29T07:29:31.226252Z","shell.execute_reply.started":"2023-03-29T07:29:30.670733Z","shell.execute_reply":"2023-03-29T07:29:31.224779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_meta_data.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:31.227979Z","iopub.execute_input":"2023-03-29T07:29:31.228456Z","iopub.status.idle":"2023-03-29T07:29:31.249124Z","shell.execute_reply.started":"2023-03-29T07:29:31.228416Z","shell.execute_reply":"2023-03-29T07:29:31.247492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# location of birds based upon latitude and longitude\n\nlatitude_column = 'latitude'  \nlongitude_column = 'longitude'  \nlabel_column = 'primary_label'  \nradius = 1  \ncenter_latitude = 0 \ncenter_longitude = 180  \nzoom_level = 1.5  \nmapbox_style = \"stamen-terrain\"  \n\nfig = px.density_mapbox(train_meta_data, \n                        lat=latitude_column,\n                        lon=longitude_column,\n                        hover_name=label_column,\n                        radius=radius,\n                        center=dict(lat=center_latitude, lon=center_longitude),\n                        zoom=zoom_level,\n                        mapbox_style=mapbox_style)\nfig.update_layout(title='Global distribution of samples')\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:31.250935Z","iopub.execute_input":"2023-03-29T07:29:31.251421Z","iopub.status.idle":"2023-03-29T07:29:31.382737Z","shell.execute_reply.started":"2023-03-29T07:29:31.251381Z","shell.execute_reply":"2023-03-29T07:29:31.381551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"taxonomy_data = pd.read_csv(\"/kaggle/input/birdclef-2023/eBird_Taxonomy_v2021.csv\")\ntaxonomy_data.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:31.384856Z","iopub.execute_input":"2023-03-29T07:29:31.385380Z","iopub.status.idle":"2023-03-29T07:29:31.458414Z","shell.execute_reply.started":"2023-03-29T07:29:31.385317Z","shell.execute_reply":"2023-03-29T07:29:31.456965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig1 = px.histogram(taxonomy_data, x=\"TAXON_ORDER\", color_discrete_sequence=['aquamarine'])\nfig1.update_layout(title_text=\"Distribution of Taxonomic Orders\")\n\nfig2 = px.box(taxonomy_data, x=\"CATEGORY\", y=\"TAXON_ORDER\", color_discrete_sequence=['red'])\nfig2.update_layout(title_text=\"Taxonomic Order Distribution by Category\")\n\nfig3 = px.scatter(taxonomy_data, x=\"FAMILY\", y=\"TAXON_ORDER\")\nfig3.update_layout(title_text=\"Taxonomic Order Distribution by Family\")\n\nfig1.show()\nfig2.show()\nfig3.show()","metadata":{"execution":{"iopub.status.busy":"2023-03-29T07:29:31.460046Z","iopub.execute_input":"2023-03-29T07:29:31.460726Z","iopub.status.idle":"2023-03-29T07:29:31.763847Z","shell.execute_reply.started":"2023-03-29T07:29:31.460684Z","shell.execute_reply":"2023-03-29T07:29:31.762508Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div style = \"height: 100px;\n  width: 800px;\n  background-color: #00f349;\">\n    <p style=\"padding: 10px;\n              color:black;\n              text-align:center;\">\n        <b>Thank you for reading. <br></br> Please do upvote if you liked the notebook If you have any suggestions please let me know<b>\n    </p>\n\n</div>","metadata":{}}]}