{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":19596,"databundleVersionId":1292430,"sourceType":"competition"},{"sourceId":1262046,"sourceType":"datasetVersion","datasetId":726424},{"sourceId":1264575,"sourceType":"datasetVersion","datasetId":725893}],"dockerImageVersionId":30635,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"\n# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-01-14T13:33:37.344088Z","iopub.execute_input":"2024-01-14T13:33:37.344357Z","iopub.status.idle":"2024-01-14T13:33:46.566431Z","shell.execute_reply.started":"2024-01-14T13:33:37.344333Z","shell.execute_reply":"2024-01-14T13:33:46.565547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt # for visualising data\n%matplotlib inline\nimport seaborn as sns\n\nimport IPython.display as ipd # for playing audio files\nimport soundfile as sf # for reading and writing audio files\nimport audioread # reading and processing audio files\nimport os # file and directory manipulation \nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:31:54.925572Z","iopub.execute_input":"2024-01-14T13:31:54.926068Z","iopub.status.idle":"2024-01-14T13:31:55.537125Z","shell.execute_reply.started":"2024-01-14T13:31:54.926032Z","shell.execute_reply":"2024-01-14T13:31:55.536036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install librosa==0.9.2","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:28:53.426045Z","iopub.execute_input":"2024-01-14T14:28:53.426930Z","iopub.status.idle":"2024-01-14T14:31:02.953781Z","shell.execute_reply.started":"2024-01-14T14:28:53.426893Z","shell.execute_reply":"2024-01-14T14:31:02.952138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/birdsong-recognition/train.csv\")\ndf","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:38:05.850221Z","iopub.execute_input":"2024-01-14T13:38:05.850685Z","iopub.status.idle":"2024-01-14T13:38:06.451012Z","shell.execute_reply.started":"2024-01-14T13:38:05.850644Z","shell.execute_reply":"2024-01-14T13:38:06.450079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:38:30.749519Z","iopub.execute_input":"2024-01-14T13:38:30.750287Z","iopub.status.idle":"2024-01-14T13:38:30.773385Z","shell.execute_reply.started":"2024-01-14T13:38:30.750254Z","shell.execute_reply":"2024-01-14T13:38:30.772455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:38:44.121068Z","iopub.execute_input":"2024-01-14T13:38:44.121776Z","iopub.status.idle":"2024-01-14T13:38:44.129347Z","shell.execute_reply.started":"2024-01-14T13:38:44.121745Z","shell.execute_reply":"2024-01-14T13:38:44.128379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:38:59.207181Z","iopub.execute_input":"2024-01-14T13:38:59.207996Z","iopub.status.idle":"2024-01-14T13:38:59.291289Z","shell.execute_reply.started":"2024-01-14T13:38:59.207961Z","shell.execute_reply":"2024-01-14T13:38:59.290363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['rating'].unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:39:12.095616Z","iopub.execute_input":"2024-01-14T13:39:12.096418Z","iopub.status.idle":"2024-01-14T13:39:12.103373Z","shell.execute_reply.started":"2024-01-14T13:39:12.096375Z","shell.execute_reply":"2024-01-14T13:39:12.102319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.playback_used.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:39:33.699065Z","iopub.execute_input":"2024-01-14T13:39:33.699408Z","iopub.status.idle":"2024-01-14T13:39:33.708722Z","shell.execute_reply.started":"2024-01-14T13:39:33.699381Z","shell.execute_reply":"2024-01-14T13:39:33.707686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.playback_used.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:39:46.828563Z","iopub.execute_input":"2024-01-14T13:39:46.829181Z","iopub.status.idle":"2024-01-14T13:39:46.839026Z","shell.execute_reply.started":"2024-01-14T13:39:46.829151Z","shell.execute_reply":"2024-01-14T13:39:46.837886Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.playback_used.fillna('no',inplace = True)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:40:14.160724Z","iopub.execute_input":"2024-01-14T13:40:14.161064Z","iopub.status.idle":"2024-01-14T13:40:14.168070Z","shell.execute_reply.started":"2024-01-14T13:40:14.161040Z","shell.execute_reply":"2024-01-14T13:40:14.166972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.playback_used.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:40:24.854332Z","iopub.execute_input":"2024-01-14T13:40:24.855033Z","iopub.status.idle":"2024-01-14T13:40:24.862309Z","shell.execute_reply.started":"2024-01-14T13:40:24.855000Z","shell.execute_reply":"2024-01-14T13:40:24.861408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ebird_code.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:40:33.346906Z","iopub.execute_input":"2024-01-14T13:40:33.347698Z","iopub.status.idle":"2024-01-14T13:40:33.359529Z","shell.execute_reply.started":"2024-01-14T13:40:33.347662Z","shell.execute_reply":"2024-01-14T13:40:33.358514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ebird_code.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:41:04.465514Z","iopub.execute_input":"2024-01-14T13:41:04.465839Z","iopub.status.idle":"2024-01-14T13:41:04.474779Z","shell.execute_reply.started":"2024-01-14T13:41:04.465815Z","shell.execute_reply":"2024-01-14T13:41:04.473713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.ebird_code.nunique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:41:39.323513Z","iopub.execute_input":"2024-01-14T13:41:39.323871Z","iopub.status.idle":"2024-01-14T13:41:39.331638Z","shell.execute_reply.started":"2024-01-14T13:41:39.323842Z","shell.execute_reply":"2024-01-14T13:41:39.330704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.channels.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:41:56.378540Z","iopub.execute_input":"2024-01-14T13:41:56.379159Z","iopub.status.idle":"2024-01-14T13:41:56.389759Z","shell.execute_reply.started":"2024-01-14T13:41:56.379125Z","shell.execute_reply":"2024-01-14T13:41:56.388880Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.channels.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:48:34.435385Z","iopub.execute_input":"2024-01-14T13:48:34.436306Z","iopub.status.idle":"2024-01-14T13:48:34.444106Z","shell.execute_reply.started":"2024-01-14T13:48:34.436273Z","shell.execute_reply":"2024-01-14T13:48:34.443001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.date.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:48:49.016615Z","iopub.execute_input":"2024-01-14T13:48:49.017312Z","iopub.status.idle":"2024-01-14T13:48:49.028110Z","shell.execute_reply.started":"2024-01-14T13:48:49.017282Z","shell.execute_reply":"2024-01-14T13:48:49.027165Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.date.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:48:58.630099Z","iopub.execute_input":"2024-01-14T13:48:58.630430Z","iopub.status.idle":"2024-01-14T13:48:58.638124Z","shell.execute_reply.started":"2024-01-14T13:48:58.630402Z","shell.execute_reply":"2024-01-14T13:48:58.637215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[['year', 'month', 'day']] = df['date'].str.split('-', expand=True)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:04.519812Z","iopub.execute_input":"2024-01-14T13:49:04.520155Z","iopub.status.idle":"2024-01-14T13:49:04.566575Z","shell.execute_reply.started":"2024-01-14T13:49:04.520128Z","shell.execute_reply":"2024-01-14T13:49:04.565804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.month.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:09.570139Z","iopub.execute_input":"2024-01-14T13:49:09.570448Z","iopub.status.idle":"2024-01-14T13:49:09.578878Z","shell.execute_reply.started":"2024-01-14T13:49:09.570425Z","shell.execute_reply":"2024-01-14T13:49:09.577929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.month.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:18.327930Z","iopub.execute_input":"2024-01-14T13:49:18.328302Z","iopub.status.idle":"2024-01-14T13:49:18.339934Z","shell.execute_reply.started":"2024-01-14T13:49:18.328272Z","shell.execute_reply":"2024-01-14T13:49:18.339065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['month'] = df['month'].replace('00', '05')","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:25.023066Z","iopub.execute_input":"2024-01-14T13:49:25.023657Z","iopub.status.idle":"2024-01-14T13:49:25.034052Z","shell.execute_reply.started":"2024-01-14T13:49:25.023624Z","shell.execute_reply":"2024-01-14T13:49:25.033098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.month.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:30.313160Z","iopub.execute_input":"2024-01-14T13:49:30.314106Z","iopub.status.idle":"2024-01-14T13:49:30.323378Z","shell.execute_reply.started":"2024-01-14T13:49:30.314072Z","shell.execute_reply":"2024-01-14T13:49:30.322430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"i have split the date into month so we can analyze that in which month bird are seen.","metadata":{}},{"cell_type":"code","source":"df = df.drop(['year', 'day'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:35.849163Z","iopub.execute_input":"2024-01-14T13:49:35.850240Z","iopub.status.idle":"2024-01-14T13:49:35.866298Z","shell.execute_reply.started":"2024-01-14T13:49:35.850190Z","shell.execute_reply":"2024-01-14T13:49:35.865273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.pitch.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:42.180963Z","iopub.execute_input":"2024-01-14T13:49:42.181300Z","iopub.status.idle":"2024-01-14T13:49:42.192198Z","shell.execute_reply.started":"2024-01-14T13:49:42.181273Z","shell.execute_reply":"2024-01-14T13:49:42.191225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.pitch.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:49.307017Z","iopub.execute_input":"2024-01-14T13:49:49.307379Z","iopub.status.idle":"2024-01-14T13:49:49.315541Z","shell.execute_reply.started":"2024-01-14T13:49:49.307351Z","shell.execute_reply":"2024-01-14T13:49:49.314471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.pitch.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:49:54.803141Z","iopub.execute_input":"2024-01-14T13:49:54.803505Z","iopub.status.idle":"2024-01-14T13:49:54.814226Z","shell.execute_reply.started":"2024-01-14T13:49:54.803458Z","shell.execute_reply":"2024-01-14T13:49:54.813362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:00.093503Z","iopub.execute_input":"2024-01-14T13:50:00.094272Z","iopub.status.idle":"2024-01-14T13:50:00.100421Z","shell.execute_reply.started":"2024-01-14T13:50:00.094240Z","shell.execute_reply":"2024-01-14T13:50:00.099511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.speed.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:04.986136Z","iopub.execute_input":"2024-01-14T13:50:04.986665Z","iopub.status.idle":"2024-01-14T13:50:04.996548Z","shell.execute_reply.started":"2024-01-14T13:50:04.986638Z","shell.execute_reply":"2024-01-14T13:50:04.995598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.species.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:09.764112Z","iopub.execute_input":"2024-01-14T13:50:09.764960Z","iopub.status.idle":"2024-01-14T13:50:09.775507Z","shell.execute_reply.started":"2024-01-14T13:50:09.764926Z","shell.execute_reply":"2024-01-14T13:50:09.774590Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.number_of_notes.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:14.593259Z","iopub.execute_input":"2024-01-14T13:50:14.594041Z","iopub.status.idle":"2024-01-14T13:50:14.602537Z","shell.execute_reply.started":"2024-01-14T13:50:14.594002Z","shell.execute_reply":"2024-01-14T13:50:14.601503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.title.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:19.428249Z","iopub.execute_input":"2024-01-14T13:50:19.428620Z","iopub.status.idle":"2024-01-14T13:50:19.439263Z","shell.execute_reply.started":"2024-01-14T13:50:19.428591Z","shell.execute_reply":"2024-01-14T13:50:19.438437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.title.nunique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:24.143456Z","iopub.execute_input":"2024-01-14T13:50:24.143865Z","iopub.status.idle":"2024-01-14T13:50:24.158562Z","shell.execute_reply.started":"2024-01-14T13:50:24.143834Z","shell.execute_reply":"2024-01-14T13:50:24.157550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.secondary_labels.nunique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:29.344847Z","iopub.execute_input":"2024-01-14T13:50:29.345214Z","iopub.status.idle":"2024-01-14T13:50:29.355386Z","shell.execute_reply.started":"2024-01-14T13:50:29.345185Z","shell.execute_reply":"2024-01-14T13:50:29.354637Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.secondary_labels.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:33.684724Z","iopub.execute_input":"2024-01-14T13:50:33.685064Z","iopub.status.idle":"2024-01-14T13:50:33.694195Z","shell.execute_reply.started":"2024-01-14T13:50:33.685037Z","shell.execute_reply":"2024-01-14T13:50:33.693325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.bird_seen.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:38.806561Z","iopub.execute_input":"2024-01-14T13:50:38.806918Z","iopub.status.idle":"2024-01-14T13:50:38.817081Z","shell.execute_reply.started":"2024-01-14T13:50:38.806890Z","shell.execute_reply":"2024-01-14T13:50:38.816193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.bird_seen.fillna('yes', inplace=True)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:43.831058Z","iopub.execute_input":"2024-01-14T13:50:43.831421Z","iopub.status.idle":"2024-01-14T13:50:43.839683Z","shell.execute_reply.started":"2024-01-14T13:50:43.831392Z","shell.execute_reply":"2024-01-14T13:50:43.838416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.bird_seen.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:48.603408Z","iopub.execute_input":"2024-01-14T13:50:48.604037Z","iopub.status.idle":"2024-01-14T13:50:48.611800Z","shell.execute_reply.started":"2024-01-14T13:50:48.604008Z","shell.execute_reply":"2024-01-14T13:50:48.610722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"replace the not specified value to 'yes' as most frequent value is yes.","metadata":{}},{"cell_type":"code","source":"df.sci_name.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:53.267892Z","iopub.execute_input":"2024-01-14T13:50:53.268238Z","iopub.status.idle":"2024-01-14T13:50:53.279379Z","shell.execute_reply.started":"2024-01-14T13:50:53.268210Z","shell.execute_reply":"2024-01-14T13:50:53.278442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.sci_name.nunique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:50:57.459164Z","iopub.execute_input":"2024-01-14T13:50:57.459533Z","iopub.status.idle":"2024-01-14T13:50:57.467415Z","shell.execute_reply.started":"2024-01-14T13:50:57.459506Z","shell.execute_reply":"2024-01-14T13:50:57.466454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.sci_name.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:02.351383Z","iopub.execute_input":"2024-01-14T13:51:02.351773Z","iopub.status.idle":"2024-01-14T13:51:02.365434Z","shell.execute_reply.started":"2024-01-14T13:51:02.351743Z","shell.execute_reply":"2024-01-14T13:51:02.364191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.location.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:07.626779Z","iopub.execute_input":"2024-01-14T13:51:07.627352Z","iopub.status.idle":"2024-01-14T13:51:07.639228Z","shell.execute_reply.started":"2024-01-14T13:51:07.627324Z","shell.execute_reply":"2024-01-14T13:51:07.638164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.location.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:12.593640Z","iopub.execute_input":"2024-01-14T13:51:12.594323Z","iopub.status.idle":"2024-01-14T13:51:12.605265Z","shell.execute_reply.started":"2024-01-14T13:51:12.594286Z","shell.execute_reply":"2024-01-14T13:51:12.604250Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.latitude","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:16.635120Z","iopub.execute_input":"2024-01-14T13:51:16.636047Z","iopub.status.idle":"2024-01-14T13:51:16.644499Z","shell.execute_reply.started":"2024-01-14T13:51:16.636007Z","shell.execute_reply":"2024-01-14T13:51:16.643427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:20.925801Z","iopub.execute_input":"2024-01-14T13:51:20.926139Z","iopub.status.idle":"2024-01-14T13:51:21.004964Z","shell.execute_reply.started":"2024-01-14T13:51:20.926111Z","shell.execute_reply":"2024-01-14T13:51:21.003988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.sampling_rate.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:28.500062Z","iopub.execute_input":"2024-01-14T13:51:28.500397Z","iopub.status.idle":"2024-01-14T13:51:28.507715Z","shell.execute_reply.started":"2024-01-14T13:51:28.500369Z","shell.execute_reply":"2024-01-14T13:51:28.506831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('sampling_rate', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:41.553076Z","iopub.execute_input":"2024-01-14T13:51:41.553426Z","iopub.status.idle":"2024-01-14T13:51:41.568601Z","shell.execute_reply.started":"2024-01-14T13:51:41.553399Z","shell.execute_reply":"2024-01-14T13:51:41.567680Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"i do not think sampling rate is needed so i have dropped it .","metadata":{}},{"cell_type":"code","source":"df.type.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:45.858388Z","iopub.execute_input":"2024-01-14T13:51:45.858777Z","iopub.status.idle":"2024-01-14T13:51:45.867533Z","shell.execute_reply.started":"2024-01-14T13:51:45.858745Z","shell.execute_reply":"2024-01-14T13:51:45.866430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.type.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:51:52.504571Z","iopub.execute_input":"2024-01-14T13:51:52.504921Z","iopub.status.idle":"2024-01-14T13:51:52.517022Z","shell.execute_reply.started":"2024-01-14T13:51:52.504894Z","shell.execute_reply":"2024-01-14T13:51:52.516119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":" df = df.drop('type', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:52:11.452873Z","iopub.execute_input":"2024-01-14T13:52:11.453596Z","iopub.status.idle":"2024-01-14T13:52:11.470011Z","shell.execute_reply.started":"2024-01-14T13:52:11.453566Z","shell.execute_reply":"2024-01-14T13:52:11.469066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"I donnot think that this will help so i have dropped it .","metadata":{}},{"cell_type":"code","source":"df.elevation.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:52:17.063043Z","iopub.execute_input":"2024-01-14T13:52:17.063420Z","iopub.status.idle":"2024-01-14T13:52:17.073346Z","shell.execute_reply.started":"2024-01-14T13:52:17.063389Z","shell.execute_reply":"2024-01-14T13:52:17.072399Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.elevation.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:52:22.248135Z","iopub.execute_input":"2024-01-14T13:52:22.248472Z","iopub.status.idle":"2024-01-14T13:52:22.259468Z","shell.execute_reply.started":"2024-01-14T13:52:22.248444Z","shell.execute_reply":"2024-01-14T13:52:22.258465Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['elevation'] = df['elevation'].str.replace(' m','', regex=True)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:52:27.353985Z","iopub.execute_input":"2024-01-14T13:52:27.354661Z","iopub.status.idle":"2024-01-14T13:52:27.380668Z","shell.execute_reply.started":"2024-01-14T13:52:27.354629Z","shell.execute_reply":"2024-01-14T13:52:27.379706Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.elevation.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:52:37.452616Z","iopub.execute_input":"2024-01-14T13:52:37.453223Z","iopub.status.idle":"2024-01-14T13:52:37.462086Z","shell.execute_reply.started":"2024-01-14T13:52:37.453193Z","shell.execute_reply":"2024-01-14T13:52:37.461273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['elevation'] = df['elevation'].replace('?', np.nan)\ndf['elevation'] = df['elevation'].replace('0', np.nan)\ndf['elevation'] = df['elevation'].replace('-', np.nan)\ndf['elevation'] = df['elevation'].replace('Unknown', np.nan)\ndf['elevation'] = df['elevation'].replace('', np.nan)\ndf['elevation'] = df['elevation'].replace('??', np.nan)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:52:43.805389Z","iopub.execute_input":"2024-01-14T13:52:43.806303Z","iopub.status.idle":"2024-01-14T13:52:43.839240Z","shell.execute_reply.started":"2024-01-14T13:52:43.806269Z","shell.execute_reply":"2024-01-14T13:52:43.838509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.elevation.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:52:49.369127Z","iopub.execute_input":"2024-01-14T13:52:49.369895Z","iopub.status.idle":"2024-01-14T13:52:49.379187Z","shell.execute_reply.started":"2024-01-14T13:52:49.369865Z","shell.execute_reply":"2024-01-14T13:52:49.378270Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.elevation.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:52:54.279667Z","iopub.execute_input":"2024-01-14T13:52:54.280379Z","iopub.status.idle":"2024-01-14T13:52:54.293172Z","shell.execute_reply.started":"2024-01-14T13:52:54.280337Z","shell.execute_reply":"2024-01-14T13:52:54.292109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['elevation'] = df['elevation'].str.replace('m','')","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:53:00.113298Z","iopub.execute_input":"2024-01-14T13:53:00.114070Z","iopub.status.idle":"2024-01-14T13:53:00.129829Z","shell.execute_reply.started":"2024-01-14T13:53:00.114038Z","shell.execute_reply":"2024-01-14T13:53:00.128909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"i have split the elevation and convert into float type .","metadata":{}},{"cell_type":"code","source":"df.description.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:53:09.802885Z","iopub.execute_input":"2024-01-14T13:53:09.803234Z","iopub.status.idle":"2024-01-14T13:53:09.813605Z","shell.execute_reply.started":"2024-01-14T13:53:09.803204Z","shell.execute_reply":"2024-01-14T13:53:09.812702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.description.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:53:21.428766Z","iopub.execute_input":"2024-01-14T13:53:21.429604Z","iopub.status.idle":"2024-01-14T13:53:21.443629Z","shell.execute_reply.started":"2024-01-14T13:53:21.429560Z","shell.execute_reply":"2024-01-14T13:53:21.442463Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('description', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:53:41.519780Z","iopub.execute_input":"2024-01-14T13:53:41.520118Z","iopub.status.idle":"2024-01-14T13:53:41.532952Z","shell.execute_reply.started":"2024-01-14T13:53:41.520091Z","shell.execute_reply":"2024-01-14T13:53:41.531976Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"i have dropped description as i don't think that it will help in eda.","metadata":{}},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:53:47.506219Z","iopub.execute_input":"2024-01-14T13:53:47.506585Z","iopub.status.idle":"2024-01-14T13:53:47.512822Z","shell.execute_reply.started":"2024-01-14T13:53:47.506556Z","shell.execute_reply":"2024-01-14T13:53:47.511802Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.bitrate_of_mp3","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:53:53.240191Z","iopub.execute_input":"2024-01-14T13:53:53.240984Z","iopub.status.idle":"2024-01-14T13:53:53.249273Z","shell.execute_reply.started":"2024-01-14T13:53:53.240944Z","shell.execute_reply":"2024-01-14T13:53:53.248373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('bitrate_of_mp3', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:53:58.141269Z","iopub.execute_input":"2024-01-14T13:53:58.141951Z","iopub.status.idle":"2024-01-14T13:53:58.157550Z","shell.execute_reply.started":"2024-01-14T13:53:58.141915Z","shell.execute_reply":"2024-01-14T13:53:58.156519Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.file_type.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:02.977509Z","iopub.execute_input":"2024-01-14T13:54:02.977877Z","iopub.status.idle":"2024-01-14T13:54:02.988054Z","shell.execute_reply.started":"2024-01-14T13:54:02.977848Z","shell.execute_reply":"2024-01-14T13:54:02.987134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.volume.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:08.668429Z","iopub.execute_input":"2024-01-14T13:54:08.669262Z","iopub.status.idle":"2024-01-14T13:54:08.680014Z","shell.execute_reply.started":"2024-01-14T13:54:08.669229Z","shell.execute_reply":"2024-01-14T13:54:08.679024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.volume.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:16.107716Z","iopub.execute_input":"2024-01-14T13:54:16.108519Z","iopub.status.idle":"2024-01-14T13:54:16.116900Z","shell.execute_reply.started":"2024-01-14T13:54:16.108469Z","shell.execute_reply":"2024-01-14T13:54:16.115916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('volume', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:20.987388Z","iopub.execute_input":"2024-01-14T13:54:20.987772Z","iopub.status.idle":"2024-01-14T13:54:21.004122Z","shell.execute_reply.started":"2024-01-14T13:54:20.987741Z","shell.execute_reply":"2024-01-14T13:54:21.003116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:27.096268Z","iopub.execute_input":"2024-01-14T13:54:27.096637Z","iopub.status.idle":"2024-01-14T13:54:27.103323Z","shell.execute_reply.started":"2024-01-14T13:54:27.096609Z","shell.execute_reply":"2024-01-14T13:54:27.102298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.background.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:32.318964Z","iopub.execute_input":"2024-01-14T13:54:32.319330Z","iopub.status.idle":"2024-01-14T13:54:32.328802Z","shell.execute_reply.started":"2024-01-14T13:54:32.319298Z","shell.execute_reply":"2024-01-14T13:54:32.327801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('background', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:36.967314Z","iopub.execute_input":"2024-01-14T13:54:36.968021Z","iopub.status.idle":"2024-01-14T13:54:36.982250Z","shell.execute_reply.started":"2024-01-14T13:54:36.967988Z","shell.execute_reply":"2024-01-14T13:54:36.981078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.xc_id.info()\n","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:42.216996Z","iopub.execute_input":"2024-01-14T13:54:42.217781Z","iopub.status.idle":"2024-01-14T13:54:42.227444Z","shell.execute_reply.started":"2024-01-14T13:54:42.217749Z","shell.execute_reply":"2024-01-14T13:54:42.226395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.xc_id.unique","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:54:47.059742Z","iopub.execute_input":"2024-01-14T13:54:47.060143Z","iopub.status.idle":"2024-01-14T13:54:47.067359Z","shell.execute_reply.started":"2024-01-14T13:54:47.060097Z","shell.execute_reply":"2024-01-14T13:54:47.066525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('xc_id', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:55:22.174928Z","iopub.execute_input":"2024-01-14T13:55:22.175283Z","iopub.status.idle":"2024-01-14T13:55:22.189841Z","shell.execute_reply.started":"2024-01-14T13:55:22.175254Z","shell.execute_reply":"2024-01-14T13:55:22.188900Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.url.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:55:27.533579Z","iopub.execute_input":"2024-01-14T13:55:27.534245Z","iopub.status.idle":"2024-01-14T13:55:27.545407Z","shell.execute_reply.started":"2024-01-14T13:55:27.534214Z","shell.execute_reply":"2024-01-14T13:55:27.544144Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.url.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:55:31.607883Z","iopub.execute_input":"2024-01-14T13:55:31.608755Z","iopub.status.idle":"2024-01-14T13:55:31.618443Z","shell.execute_reply.started":"2024-01-14T13:55:31.608717Z","shell.execute_reply":"2024-01-14T13:55:31.617653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('url', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:55:36.035713Z","iopub.execute_input":"2024-01-14T13:55:36.036028Z","iopub.status.idle":"2024-01-14T13:55:36.048941Z","shell.execute_reply.started":"2024-01-14T13:55:36.036005Z","shell.execute_reply":"2024-01-14T13:55:36.048043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:55:40.864947Z","iopub.execute_input":"2024-01-14T13:55:40.865312Z","iopub.status.idle":"2024-01-14T13:55:40.871711Z","shell.execute_reply.started":"2024-01-14T13:55:40.865283Z","shell.execute_reply":"2024-01-14T13:55:40.870703Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.country.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:55:45.897956Z","iopub.execute_input":"2024-01-14T13:55:45.898689Z","iopub.status.idle":"2024-01-14T13:55:45.908403Z","shell.execute_reply.started":"2024-01-14T13:55:45.898654Z","shell.execute_reply":"2024-01-14T13:55:45.907522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.author.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:55:52.659910Z","iopub.execute_input":"2024-01-14T13:55:52.660253Z","iopub.status.idle":"2024-01-14T13:55:52.671024Z","shell.execute_reply.started":"2024-01-14T13:55:52.660222Z","shell.execute_reply":"2024-01-14T13:55:52.670031Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.author.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:55:58.563335Z","iopub.execute_input":"2024-01-14T13:55:58.563977Z","iopub.status.idle":"2024-01-14T13:55:58.576753Z","shell.execute_reply.started":"2024-01-14T13:55:58.563943Z","shell.execute_reply":"2024-01-14T13:55:58.575827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.author.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:56:08.429667Z","iopub.execute_input":"2024-01-14T13:56:08.430045Z","iopub.status.idle":"2024-01-14T13:56:08.441390Z","shell.execute_reply.started":"2024-01-14T13:56:08.430018Z","shell.execute_reply":"2024-01-14T13:56:08.440616Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('author', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:56:15.031093Z","iopub.execute_input":"2024-01-14T13:56:15.031460Z","iopub.status.idle":"2024-01-14T13:56:15.044865Z","shell.execute_reply.started":"2024-01-14T13:56:15.031430Z","shell.execute_reply":"2024-01-14T13:56:15.044066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:56:20.022552Z","iopub.execute_input":"2024-01-14T13:56:20.023577Z","iopub.status.idle":"2024-01-14T13:56:20.031370Z","shell.execute_reply.started":"2024-01-14T13:56:20.023531Z","shell.execute_reply":"2024-01-14T13:56:20.030395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df.primary_label.nunique())\ndf.primary_label.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:56:26.450952Z","iopub.execute_input":"2024-01-14T13:56:26.451325Z","iopub.status.idle":"2024-01-14T13:56:26.465409Z","shell.execute_reply.started":"2024-01-14T13:56:26.451288Z","shell.execute_reply":"2024-01-14T13:56:26.464532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('primary_label', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:56:36.409787Z","iopub.execute_input":"2024-01-14T13:56:36.410148Z","iopub.status.idle":"2024-01-14T13:56:36.424543Z","shell.execute_reply.started":"2024-01-14T13:56:36.410102Z","shell.execute_reply":"2024-01-14T13:56:36.423527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.length.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:56:41.170349Z","iopub.execute_input":"2024-01-14T13:56:41.171304Z","iopub.status.idle":"2024-01-14T13:56:41.181719Z","shell.execute_reply.started":"2024-01-14T13:56:41.171270Z","shell.execute_reply":"2024-01-14T13:56:41.180840Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.length","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:56:58.016395Z","iopub.execute_input":"2024-01-14T13:56:58.016827Z","iopub.status.idle":"2024-01-14T13:56:58.024693Z","shell.execute_reply.started":"2024-01-14T13:56:58.016792Z","shell.execute_reply":"2024-01-14T13:56:58.023772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:57:03.225474Z","iopub.execute_input":"2024-01-14T13:57:03.225831Z","iopub.status.idle":"2024-01-14T13:57:03.232319Z","shell.execute_reply.started":"2024-01-14T13:57:03.225807Z","shell.execute_reply":"2024-01-14T13:57:03.231295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.time.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:57:08.641547Z","iopub.execute_input":"2024-01-14T13:57:08.642231Z","iopub.status.idle":"2024-01-14T13:57:08.653246Z","shell.execute_reply.started":"2024-01-14T13:57:08.642197Z","shell.execute_reply":"2024-01-14T13:57:08.651966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df.time.nunique())\ndf.time.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:57:36.690750Z","iopub.execute_input":"2024-01-14T13:57:36.691119Z","iopub.status.idle":"2024-01-14T13:57:36.701362Z","shell.execute_reply.started":"2024-01-14T13:57:36.691092Z","shell.execute_reply":"2024-01-14T13:57:36.700470Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.recordist.info()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:57:41.516739Z","iopub.execute_input":"2024-01-14T13:57:41.517456Z","iopub.status.idle":"2024-01-14T13:57:41.527886Z","shell.execute_reply.started":"2024-01-14T13:57:41.517425Z","shell.execute_reply":"2024-01-14T13:57:41.526868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df.recordist.nunique())\ndf.recordist.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:57:52.162691Z","iopub.execute_input":"2024-01-14T13:57:52.163384Z","iopub.status.idle":"2024-01-14T13:57:52.179688Z","shell.execute_reply.started":"2024-01-14T13:57:52.163353Z","shell.execute_reply":"2024-01-14T13:57:52.178825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop('recordist', axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:57:56.673193Z","iopub.execute_input":"2024-01-14T13:57:56.674056Z","iopub.status.idle":"2024-01-14T13:57:56.687580Z","shell.execute_reply.started":"2024-01-14T13:57:56.674021Z","shell.execute_reply":"2024-01-14T13:57:56.686752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:58:03.171356Z","iopub.execute_input":"2024-01-14T13:58:03.172250Z","iopub.status.idle":"2024-01-14T13:58:03.180868Z","shell.execute_reply.started":"2024-01-14T13:58:03.172217Z","shell.execute_reply":"2024-01-14T13:58:03.179667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.license.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:58:07.946235Z","iopub.execute_input":"2024-01-14T13:58:07.947048Z","iopub.status.idle":"2024-01-14T13:58:07.955297Z","shell.execute_reply.started":"2024-01-14T13:58:07.947014Z","shell.execute_reply":"2024-01-14T13:58:07.954401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:58:12.483797Z","iopub.execute_input":"2024-01-14T13:58:12.484159Z","iopub.status.idle":"2024-01-14T13:58:12.490206Z","shell.execute_reply.started":"2024-01-14T13:58:12.484130Z","shell.execute_reply":"2024-01-14T13:58:12.489245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\n\nplt.figure(figsize=(10, 6))\n\nsns.countplot(x='rating', data=df, order=df['rating'].value_counts().index, palette='viridis')\nplt.title(\"Ratings distribution\")\nplt.xlabel(\"Ratings\")\nplt.ylabel(\"Count\")\nplt.xticks(rotation=45)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:59:20.385727Z","iopub.execute_input":"2024-01-14T13:59:20.386343Z","iopub.status.idle":"2024-01-14T13:59:21.322855Z","shell.execute_reply.started":"2024-01-14T13:59:20.386303Z","shell.execute_reply":"2024-01-14T13:59:21.321779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['month']=df['month'].astype(int)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:59:34.023903Z","iopub.execute_input":"2024-01-14T13:59:34.024258Z","iopub.status.idle":"2024-01-14T13:59:34.029705Z","shell.execute_reply.started":"2024-01-14T13:59:34.024231Z","shell.execute_reply":"2024-01-14T13:59:34.028618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.month.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:59:34.417657Z","iopub.execute_input":"2024-01-14T13:59:34.418038Z","iopub.status.idle":"2024-01-14T13:59:34.425731Z","shell.execute_reply.started":"2024-01-14T13:59:34.418007Z","shell.execute_reply":"2024-01-14T13:59:34.424675Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bird_month_counts = df.groupby(['month', 'species']).size().reset_index(name='Count')\n\n# Find the top 10 birds based on overall sightings\ntop_birds = bird_month_counts.groupby('species')['Count'].sum().nlargest(5).index\n\n# Filter the data for the top 10 birds\ntop_bird_month_counts = bird_month_counts[bird_month_counts['species'].isin(top_birds)]\n\n# Create a line plot using Seaborn\nplt.figure(figsize=(14, 8))\nsns.lineplot(x='month', y='Count', hue='species', data=top_bird_month_counts, marker='o', palette='muted')\nplt.xlabel('Month')\nplt.ylabel('Count')\nplt.title('Top 10 Bird Sightings Over Months')\nplt.legend(title='species', bbox_to_anchor=(1, 1))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:59:41.682594Z","iopub.execute_input":"2024-01-14T13:59:41.683238Z","iopub.status.idle":"2024-01-14T13:59:42.138006Z","shell.execute_reply.started":"2024-01-14T13:59:41.683206Z","shell.execute_reply":"2024-01-14T13:59:42.137132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:59:50.482064Z","iopub.execute_input":"2024-01-14T13:59:50.482452Z","iopub.status.idle":"2024-01-14T13:59:50.488524Z","shell.execute_reply.started":"2024-01-14T13:59:50.482422Z","shell.execute_reply":"2024-01-14T13:59:50.487740Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"unique_values = df['species'].unique()[:5]\nunique_values","metadata":{"execution":{"iopub.status.busy":"2024-01-14T13:59:56.076033Z","iopub.execute_input":"2024-01-14T13:59:56.076518Z","iopub.status.idle":"2024-01-14T13:59:56.085662Z","shell.execute_reply.started":"2024-01-14T13:59:56.076460Z","shell.execute_reply":"2024-01-14T13:59:56.084665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dfs = []\n\n# Extract 2 rows for each unique value\nfor value in unique_values:\n    # Filter rows based on the unique value\n    subset = df[df['species'] == value].head(2)\n    \n    # Append the subset to the result DataFrame\n    dfs.append(subset)\n\ndf_for_FE = pd.concat(dfs, ignore_index=True)\ndf_for_FE","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:00:00.873807Z","iopub.execute_input":"2024-01-14T14:00:00.874253Z","iopub.status.idle":"2024-01-14T14:00:00.924924Z","shell.execute_reply.started":"2024-01-14T14:00:00.874217Z","shell.execute_reply":"2024-01-14T14:00:00.923916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import librosa \ny1,sr1 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/aldfly/XC134874.mp3\")\ny2,sr2 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/aldfly/XC135454.mp3\")","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:01:36.904451Z","iopub.execute_input":"2024-01-14T14:01:36.904844Z","iopub.status.idle":"2024-01-14T14:01:45.591163Z","shell.execute_reply.started":"2024-01-14T14:01:36.904817Z","shell.execute_reply":"2024-01-14T14:01:45.590261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import IPython.display as ipd\n\nprint(\"Audio1\")\nipd.Audio(y1, rate=sr1)\n","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:02:30.316653Z","iopub.execute_input":"2024-01-14T14:02:30.317262Z","iopub.status.idle":"2024-01-14T14:02:30.351105Z","shell.execute_reply.started":"2024-01-14T14:02:30.317232Z","shell.execute_reply":"2024-01-14T14:02:30.350148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y3,sr3 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/ameavo/XC133080.mp3\")\ny4,sr4 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/ameavo/XC139829.mp3\")","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:02:38.463640Z","iopub.execute_input":"2024-01-14T14:02:38.464012Z","iopub.status.idle":"2024-01-14T14:02:38.526129Z","shell.execute_reply.started":"2024-01-14T14:02:38.463986Z","shell.execute_reply":"2024-01-14T14:02:38.525381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Audio3\")\nipd.Audio(y3, rate=sr3)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:02:41.507890Z","iopub.execute_input":"2024-01-14T14:02:41.508215Z","iopub.status.idle":"2024-01-14T14:02:41.523631Z","shell.execute_reply.started":"2024-01-14T14:02:41.508192Z","shell.execute_reply":"2024-01-14T14:02:41.522793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y5,sr5 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/amebit/XC127371.mp3\")\ny6,sr6 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/amebit/XC130058.mp3\")","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:02:58.385562Z","iopub.execute_input":"2024-01-14T14:02:58.385939Z","iopub.status.idle":"2024-01-14T14:02:58.492954Z","shell.execute_reply.started":"2024-01-14T14:02:58.385909Z","shell.execute_reply":"2024-01-14T14:02:58.492162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Audio5\")\nipd.Audio(y5, rate=sr5)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:03:03.736619Z","iopub.execute_input":"2024-01-14T14:03:03.737490Z","iopub.status.idle":"2024-01-14T14:03:03.763963Z","shell.execute_reply.started":"2024-01-14T14:03:03.737444Z","shell.execute_reply":"2024-01-14T14:03:03.763128Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y7,sr7 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/amecro/XC109768.mp3\")\ny8,sr8 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/amecro/XC112598.mp3\")","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:03:09.374924Z","iopub.execute_input":"2024-01-14T14:03:09.375298Z","iopub.status.idle":"2024-01-14T14:03:09.600854Z","shell.execute_reply.started":"2024-01-14T14:03:09.375269Z","shell.execute_reply":"2024-01-14T14:03:09.599886Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Audio7\")\nipd.Audio(y7, rate=sr7)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:03:40.040330Z","iopub.execute_input":"2024-01-14T14:03:40.040699Z","iopub.status.idle":"2024-01-14T14:03:40.062536Z","shell.execute_reply.started":"2024-01-14T14:03:40.040670Z","shell.execute_reply":"2024-01-14T14:03:40.061671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y9,sr9 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/amegfi/XC109299.mp3\")\ny10,sr10 = librosa.load(\"/kaggle/input/birdsong-recognition/train_audio/amegfi/XC109300.mp3\")","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:03:45.074296Z","iopub.execute_input":"2024-01-14T14:03:45.074961Z","iopub.status.idle":"2024-01-14T14:03:45.679379Z","shell.execute_reply.started":"2024-01-14T14:03:45.074929Z","shell.execute_reply":"2024-01-14T14:03:45.678390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Audio9\")\nipd.Audio(y9, rate=sr9)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:03:53.923908Z","iopub.execute_input":"2024-01-14T14:03:53.924223Z","iopub.status.idle":"2024-01-14T14:03:54.033089Z","shell.execute_reply.started":"2024-01-14T14:03:53.924199Z","shell.execute_reply":"2024-01-14T14:03:54.031585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"zcr1 = librosa.feature.zero_crossing_rate(y1)\nprint(zcr1)\nprint(\"zcr1\")\nprint('max:',zcr1.max())\nprint('min:',zcr1.min())\nprint(\"-------------------------------\")\nzcr2 = librosa.feature.zero_crossing_rate(y2)\nprint(\"zcr2\")\nprint('max:',zcr2.max())\nprint('min:',zcr2.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:02.163968Z","iopub.execute_input":"2024-01-14T14:04:02.164326Z","iopub.status.idle":"2024-01-14T14:04:03.367394Z","shell.execute_reply.started":"2024-01-14T14:04:02.164298Z","shell.execute_reply":"2024-01-14T14:04:03.366395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"zcr3 = librosa.feature.zero_crossing_rate(y3)\nprint(\"zcr3\")\nprint('max:',zcr3.max())\nprint('min:',zcr3.min())\nprint(\"-------------------------------\")\nzcr4 = librosa.feature.zero_crossing_rate(y4)\nprint(\"zcr4\")\nprint('max:',zcr4.max())\nprint('min:',zcr4.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:08.703521Z","iopub.execute_input":"2024-01-14T14:04:08.703870Z","iopub.status.idle":"2024-01-14T14:04:08.723394Z","shell.execute_reply.started":"2024-01-14T14:04:08.703841Z","shell.execute_reply":"2024-01-14T14:04:08.722542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"zcr5 = librosa.feature.zero_crossing_rate(y5)\nprint(\"zcr5\")\nprint('max:',zcr5.max())\nprint('min:',zcr5.min())\nprint(\"-------------------------------\")\nzcr6 = librosa.feature.zero_crossing_rate(y6)\nprint(\"zcr6\")\nprint('max:',zcr6.max())\nprint('min:',zcr6.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:13.805650Z","iopub.execute_input":"2024-01-14T14:04:13.806030Z","iopub.status.idle":"2024-01-14T14:04:13.830163Z","shell.execute_reply.started":"2024-01-14T14:04:13.805999Z","shell.execute_reply":"2024-01-14T14:04:13.829294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":" zcr7 = librosa.feature.zero_crossing_rate(y7)\nprint(\"zcr7\")\nprint('max:',zcr7.max())\nprint('min:',zcr7.min())\nprint(\"-------------------------------\")\nzcr8 = librosa.feature.zero_crossing_rate(y8)\nprint(\"zcr8\")\nprint('max:',zcr8.max())\nprint('min:',zcr8.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:18.152052Z","iopub.execute_input":"2024-01-14T14:04:18.152947Z","iopub.status.idle":"2024-01-14T14:04:18.214433Z","shell.execute_reply.started":"2024-01-14T14:04:18.152910Z","shell.execute_reply":"2024-01-14T14:04:18.213453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"zcr9 = librosa.feature.zero_crossing_rate(y9)\nprint(\"zcr9\")\nprint('max:',zcr9.max())\nprint('min:',zcr9.min())\nprint(\"-------------------------------\")\nzcr10 = librosa.feature.zero_crossing_rate(y10)\nprint(\"zcr10\")\nprint('max:',zcr10.max())\nprint('min:',zcr10.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:22.838263Z","iopub.execute_input":"2024-01-14T14:04:22.838709Z","iopub.status.idle":"2024-01-14T14:04:22.949813Z","shell.execute_reply.started":"2024-01-14T14:04:22.838672Z","shell.execute_reply":"2024-01-14T14:04:22.948919Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"I have saw that there is no much actual difference as ranges are overlapping so cant used zcr as a distinguishable factor .","metadata":{}},{"cell_type":"code","source":"#energy (rms)\nenergy1 = librosa.feature.rms(y=y1)\nprint(energy1)\nprint('energy1')\nprint('max:',energy1.max())\nprint('min',energy1.min())\nprint('mean:',energy1.mean())\nprint(\"-------------------------------\")\nenergy2 = librosa.feature.rms(y=y2)\nprint('energy2')\nprint('max:',energy2.max())\nprint('min:',energy2.min())\nprint('mean:',energy2.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:30.692185Z","iopub.execute_input":"2024-01-14T14:04:30.692920Z","iopub.status.idle":"2024-01-14T14:04:31.067066Z","shell.execute_reply.started":"2024-01-14T14:04:30.692888Z","shell.execute_reply":"2024-01-14T14:04:31.066145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#energy (rms)\nenergy3 = librosa.feature.rms(y=y3)\nprint('energy3')\nprint('max:',energy3.max())\nprint('min:',energy3.min())\nprint('mean:',energy3.mean())\nprint(\"-------------------------------\")\nenergy4 = librosa.feature.rms(y=y4)\nprint('energy4')\nprint('max:',energy4.max())\nprint('min:',energy4.min())\nprint('mean:',energy4.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:35.273682Z","iopub.execute_input":"2024-01-14T14:04:35.274375Z","iopub.status.idle":"2024-01-14T14:04:35.457804Z","shell.execute_reply.started":"2024-01-14T14:04:35.274340Z","shell.execute_reply":"2024-01-14T14:04:35.456686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#energy (rms)\nenergy5 = librosa.feature.rms(y=y5)\nprint('energy5')\nprint('max:',energy5.max())\nprint('min:',energy5.min())\nprint('mean:',energy5.mean())\nprint(\"-------------------------------\")\nenergy6 = librosa.feature.rms(y=y6)\nprint('energy6')\nprint('max:',energy6.max())\nprint('min:',energy6.min())\nprint('mean:',energy6.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:39.904687Z","iopub.execute_input":"2024-01-14T14:04:39.905034Z","iopub.status.idle":"2024-01-14T14:04:40.165337Z","shell.execute_reply.started":"2024-01-14T14:04:39.905008Z","shell.execute_reply":"2024-01-14T14:04:40.164441Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#energy (rms)\nenergy7 = librosa.feature.rms(y=y7)\nprint('energy7')\nprint('max:',energy7.max())\nprint('min:',energy7.min())\nprint('mean:',energy7.mean())\nprint(\"-------------------------------\")\nenergy8 = librosa.feature.rms(y=y8)\nprint('energy8')\nprint('max:',energy8.max())\nprint('min:',energy8.min())\nprint('mean:',energy8.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:44.644255Z","iopub.execute_input":"2024-01-14T14:04:44.644645Z","iopub.status.idle":"2024-01-14T14:04:45.519123Z","shell.execute_reply.started":"2024-01-14T14:04:44.644614Z","shell.execute_reply":"2024-01-14T14:04:45.518223Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#energy (rms)\nenergy9 = librosa.feature.rms(y=y9)\nprint('energy9')\nprint('max:',energy9.max())\nprint('min:',energy9.min())\nprint('mean:',energy9.mean())\nprint(\"-------------------------------\")\nenergy10 = librosa.feature.rms(y=y10)\nprint('energy10')\nprint('max:',energy10.max())\nprint('min:',energy10.min())\nprint('mean:',energy10.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:48.898626Z","iopub.execute_input":"2024-01-14T14:04:48.898986Z","iopub.status.idle":"2024-01-14T14:04:50.541806Z","shell.execute_reply.started":"2024-01-14T14:04:48.898957Z","shell.execute_reply":"2024-01-14T14:04:50.540906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"energy values are also overlapping so cannot used them ","metadata":{}},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y1))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr1, roll_percent=0.85)\nprint(\"audio1 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:04:55.588950Z","iopub.execute_input":"2024-01-14T14:04:55.589827Z","iopub.status.idle":"2024-01-14T14:04:55.638872Z","shell.execute_reply.started":"2024-01-14T14:04:55.589792Z","shell.execute_reply":"2024-01-14T14:04:55.637806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y2))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr2, roll_percent=0.85)\nprint(\"audio2 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:00.737811Z","iopub.execute_input":"2024-01-14T14:05:00.738402Z","iopub.status.idle":"2024-01-14T14:05:00.820080Z","shell.execute_reply.started":"2024-01-14T14:05:00.738369Z","shell.execute_reply":"2024-01-14T14:05:00.818950Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y3))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr3, roll_percent=0.85)\nprint(\"audio3 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:05.126917Z","iopub.execute_input":"2024-01-14T14:05:05.127645Z","iopub.status.idle":"2024-01-14T14:05:05.152259Z","shell.execute_reply.started":"2024-01-14T14:05:05.127610Z","shell.execute_reply":"2024-01-14T14:05:05.151335Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y4))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr4, roll_percent=0.85)\nprint(\"audio4 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:11.351581Z","iopub.execute_input":"2024-01-14T14:05:11.352306Z","iopub.status.idle":"2024-01-14T14:05:11.385501Z","shell.execute_reply.started":"2024-01-14T14:05:11.352270Z","shell.execute_reply":"2024-01-14T14:05:11.384516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y5))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr5, roll_percent=0.85)\nprint(\"audio5 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:15.649971Z","iopub.execute_input":"2024-01-14T14:05:15.650337Z","iopub.status.idle":"2024-01-14T14:05:15.691339Z","shell.execute_reply.started":"2024-01-14T14:05:15.650307Z","shell.execute_reply":"2024-01-14T14:05:15.690263Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y5))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr5, roll_percent=0.85)\nprint(\"audio5 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:20.002409Z","iopub.execute_input":"2024-01-14T14:05:20.003157Z","iopub.status.idle":"2024-01-14T14:05:20.041213Z","shell.execute_reply.started":"2024-01-14T14:05:20.003124Z","shell.execute_reply":"2024-01-14T14:05:20.040219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y6))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr6, roll_percent=0.85)\nprint(\"audio6 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:28.689143Z","iopub.execute_input":"2024-01-14T14:05:28.690055Z","iopub.status.idle":"2024-01-14T14:05:28.730905Z","shell.execute_reply.started":"2024-01-14T14:05:28.690019Z","shell.execute_reply":"2024-01-14T14:05:28.729963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y7))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr7, roll_percent=0.85)\nprint(\"audio7 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:33.088627Z","iopub.execute_input":"2024-01-14T14:05:33.088979Z","iopub.status.idle":"2024-01-14T14:05:33.121888Z","shell.execute_reply.started":"2024-01-14T14:05:33.088953Z","shell.execute_reply":"2024-01-14T14:05:33.120961Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y8))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr8, roll_percent=0.85)\nprint(\"audio8 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:38.311358Z","iopub.execute_input":"2024-01-14T14:05:38.311726Z","iopub.status.idle":"2024-01-14T14:05:38.540891Z","shell.execute_reply.started":"2024-01-14T14:05:38.311698Z","shell.execute_reply":"2024-01-14T14:05:38.539761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y8))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr8, roll_percent=0.85)\nprint(\"audio8 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:05:55.585506Z","iopub.execute_input":"2024-01-14T14:05:55.585887Z","iopub.status.idle":"2024-01-14T14:05:55.808574Z","shell.execute_reply.started":"2024-01-14T14:05:55.585857Z","shell.execute_reply":"2024-01-14T14:05:55.807541Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y9))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr9, roll_percent=0.85)\nprint(\"audio9 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:06:00.956797Z","iopub.execute_input":"2024-01-14T14:06:00.957524Z","iopub.status.idle":"2024-01-14T14:06:01.177414Z","shell.execute_reply.started":"2024-01-14T14:06:00.957471Z","shell.execute_reply":"2024-01-14T14:06:01.176434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral roll-off\nS, phase = librosa.magphase(librosa.stft(y10))\nrolloff = librosa.feature.spectral_rolloff(S=S, sr=sr10, roll_percent=0.85)\nprint(\"audio10 spectral rolloff:\",rolloff.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:06:10.091964Z","iopub.execute_input":"2024-01-14T14:06:10.092627Z","iopub.status.idle":"2024-01-14T14:06:10.407675Z","shell.execute_reply.started":"2024-01-14T14:06:10.092597Z","shell.execute_reply":"2024-01-14T14:06:10.406724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"spectral roll off mean value can be used as a factor as there is a little diffrence in mean value ranges.","metadata":{}},{"cell_type":"code","source":"mfcc1 = librosa.feature.mfcc(y=y1, sr=sr1)\nprint(mfcc1)\nprint(\"mfcc1\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc1, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc1, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:06:16.071290Z","iopub.execute_input":"2024-01-14T14:06:16.072040Z","iopub.status.idle":"2024-01-14T14:06:16.127213Z","shell.execute_reply.started":"2024-01-14T14:06:16.071994Z","shell.execute_reply":"2024-01-14T14:06:16.124061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc2 = librosa.feature.mfcc(y=y2, sr=sr2)\nprint(\"mfcc2\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc2, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc2, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:06:20.516407Z","iopub.execute_input":"2024-01-14T14:06:20.516986Z","iopub.status.idle":"2024-01-14T14:06:20.571475Z","shell.execute_reply.started":"2024-01-14T14:06:20.516956Z","shell.execute_reply":"2024-01-14T14:06:20.569989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc3 = librosa.feature.mfcc(y=y3, sr=sr3)\nprint(\"mfcc3\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc3, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc3, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:06:42.902376Z","iopub.execute_input":"2024-01-14T14:06:42.902743Z","iopub.status.idle":"2024-01-14T14:06:42.934891Z","shell.execute_reply.started":"2024-01-14T14:06:42.902713Z","shell.execute_reply":"2024-01-14T14:06:42.933756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc4 = librosa.feature.mfcc(y=y4, sr=sr4)\nprint(\"mfcc4\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc4, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc4, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:06:52.627589Z","iopub.execute_input":"2024-01-14T14:06:52.628393Z","iopub.status.idle":"2024-01-14T14:06:52.664464Z","shell.execute_reply.started":"2024-01-14T14:06:52.628350Z","shell.execute_reply":"2024-01-14T14:06:52.663510Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc5 = librosa.feature.mfcc(y=y5, sr=sr5)\nprint(\"mfcc5\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc5, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc5, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:06:58.517538Z","iopub.execute_input":"2024-01-14T14:06:58.517874Z","iopub.status.idle":"2024-01-14T14:06:58.551540Z","shell.execute_reply.started":"2024-01-14T14:06:58.517849Z","shell.execute_reply":"2024-01-14T14:06:58.550131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc6 = librosa.feature.mfcc(y=y6, sr=sr6)\nprint(\"mfcc6\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc6, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc6, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:03.169001Z","iopub.execute_input":"2024-01-14T14:07:03.169351Z","iopub.status.idle":"2024-01-14T14:07:03.205516Z","shell.execute_reply.started":"2024-01-14T14:07:03.169323Z","shell.execute_reply":"2024-01-14T14:07:03.204088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc7 = librosa.feature.mfcc(y=y7, sr=sr7)\nprint(\"mfcc7\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc7, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc7, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:16.894875Z","iopub.execute_input":"2024-01-14T14:07:16.895222Z","iopub.status.idle":"2024-01-14T14:07:16.925063Z","shell.execute_reply.started":"2024-01-14T14:07:16.895195Z","shell.execute_reply":"2024-01-14T14:07:16.923739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc8 = librosa.feature.mfcc(y=y8, sr=sr8)\nprint(\"mfcc8\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc8, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc8, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:23.346657Z","iopub.execute_input":"2024-01-14T14:07:23.347376Z","iopub.status.idle":"2024-01-14T14:07:23.521834Z","shell.execute_reply.started":"2024-01-14T14:07:23.347345Z","shell.execute_reply":"2024-01-14T14:07:23.519161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc9 = librosa.feature.mfcc(y=y9, sr=sr9)\nprint(\"mfcc9\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc9, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc9, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:28.974064Z","iopub.execute_input":"2024-01-14T14:07:28.974982Z","iopub.status.idle":"2024-01-14T14:07:29.139950Z","shell.execute_reply.started":"2024-01-14T14:07:28.974949Z","shell.execute_reply":"2024-01-14T14:07:29.138601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mfcc10 = librosa.feature.mfcc(y=y10, sr=sr10)\nprint(\"mfcc10\")\nprint(\"max of mean-mfcc:\",np.mean(mfcc10, axis=1).max())\nprint(\"min of mean-mfcc:\",np.mean(mfcc10, axis=1).min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:36.972156Z","iopub.execute_input":"2024-01-14T14:07:36.972500Z","iopub.status.idle":"2024-01-14T14:07:37.195615Z","shell.execute_reply.started":"2024-01-14T14:07:36.972459Z","shell.execute_reply":"2024-01-14T14:07:37.194221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#spectral flux\nonset_env = librosa.onset.onset_strength(y=y1, sr=sr1)\nprint(\"spectral flux for Audio1\")\nprint(onset_env)\nprint(onset_env.mean())\nprint(\"----------------------------------------\")\nonset_env = librosa.onset.onset_strength(y=y2, sr=sr2)\nprint(\"spectral flux for Audio2\")\nprint(onset_env.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:44.144695Z","iopub.execute_input":"2024-01-14T14:07:44.145637Z","iopub.status.idle":"2024-01-14T14:07:44.309787Z","shell.execute_reply.started":"2024-01-14T14:07:44.145600Z","shell.execute_reply":"2024-01-14T14:07:44.308859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"onset_env = librosa.onset.onset_strength(y=y3, sr=sr3)\nprint(\"spectral flux for Audio3\")\nprint(onset_env.mean())\nprint(\"----------------------------------------\")\nonset_env = librosa.onset.onset_strength(y=y4, sr=sr4)\nprint(\"spectral flux for Audio4\")\nprint(onset_env.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:49.048710Z","iopub.execute_input":"2024-01-14T14:07:49.049417Z","iopub.status.idle":"2024-01-14T14:07:49.115403Z","shell.execute_reply.started":"2024-01-14T14:07:49.049387Z","shell.execute_reply":"2024-01-14T14:07:49.114372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"onset_env = librosa.onset.onset_strength(y=y5, sr=sr5)\nprint(\"spectral flux for Audio5\")\nprint(onset_env.mean())\nprint(\"----------------------------------------\")\nonset_env = librosa.onset.onset_strength(y=y6, sr=sr6)\nprint(\"spectral flux for Audio6\")\nprint(onset_env.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:54.168548Z","iopub.execute_input":"2024-01-14T14:07:54.169311Z","iopub.status.idle":"2024-01-14T14:07:54.251803Z","shell.execute_reply.started":"2024-01-14T14:07:54.169282Z","shell.execute_reply":"2024-01-14T14:07:54.250324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"onset_env = librosa.onset.onset_strength(y=y7, sr=sr7)\nprint(\"spectral flux for Audio7\")\nprint(onset_env.mean())\nprint(\"----------------------------------------\")\nonset_env = librosa.onset.onset_strength(y=y8, sr=sr8)\nprint(\"spectral flux for Audio6\")\nprint(onset_env.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:07:58.784926Z","iopub.execute_input":"2024-01-14T14:07:58.785555Z","iopub.status.idle":"2024-01-14T14:07:59.037428Z","shell.execute_reply.started":"2024-01-14T14:07:58.785511Z","shell.execute_reply":"2024-01-14T14:07:59.035989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"onset_env = librosa.onset.onset_strength(y=y9, sr=sr9)\nprint(\"spectral flux for Audio9\")\nprint(onset_env.mean())\nprint(\"----------------------------------------\")\nonset_env = librosa.onset.onset_strength(y=y10, sr=sr10)\nprint(\"spectral flux for Audio10\")\nprint(onset_env.mean())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:08:03.572295Z","iopub.execute_input":"2024-01-14T14:08:03.573059Z","iopub.status.idle":"2024-01-14T14:08:03.975111Z","shell.execute_reply.started":"2024-01-14T14:08:03.573029Z","shell.execute_reply":"2024-01-14T14:08:03.971900Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y1))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:08:23.260427Z","iopub.execute_input":"2024-01-14T14:08:23.260878Z","iopub.status.idle":"2024-01-14T14:08:23.291085Z","shell.execute_reply.started":"2024-01-14T14:08:23.260844Z","shell.execute_reply":"2024-01-14T14:08:23.290198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y2))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:08:28.573759Z","iopub.execute_input":"2024-01-14T14:08:28.574471Z","iopub.status.idle":"2024-01-14T14:08:28.615370Z","shell.execute_reply.started":"2024-01-14T14:08:28.574442Z","shell.execute_reply":"2024-01-14T14:08:28.614529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y3))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:08:36.045798Z","iopub.execute_input":"2024-01-14T14:08:36.046127Z","iopub.status.idle":"2024-01-14T14:08:36.064116Z","shell.execute_reply.started":"2024-01-14T14:08:36.046103Z","shell.execute_reply":"2024-01-14T14:08:36.063329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y3))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:08:38.386908Z","iopub.execute_input":"2024-01-14T14:08:38.387556Z","iopub.status.idle":"2024-01-14T14:08:38.406731Z","shell.execute_reply.started":"2024-01-14T14:08:38.387513Z","shell.execute_reply":"2024-01-14T14:08:38.405771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y4))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:08:45.883622Z","iopub.execute_input":"2024-01-14T14:08:45.884320Z","iopub.status.idle":"2024-01-14T14:08:45.908673Z","shell.execute_reply.started":"2024-01-14T14:08:45.884288Z","shell.execute_reply":"2024-01-14T14:08:45.907704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y5))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:08:51.617892Z","iopub.execute_input":"2024-01-14T14:08:51.618221Z","iopub.status.idle":"2024-01-14T14:08:51.645890Z","shell.execute_reply.started":"2024-01-14T14:08:51.618195Z","shell.execute_reply":"2024-01-14T14:08:51.644967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y6))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:08:56.961718Z","iopub.execute_input":"2024-01-14T14:08:56.962051Z","iopub.status.idle":"2024-01-14T14:08:56.988553Z","shell.execute_reply.started":"2024-01-14T14:08:56.962028Z","shell.execute_reply":"2024-01-14T14:08:56.987560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y7))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:03.348029Z","iopub.execute_input":"2024-01-14T14:09:03.348414Z","iopub.status.idle":"2024-01-14T14:09:03.371553Z","shell.execute_reply.started":"2024-01-14T14:09:03.348382Z","shell.execute_reply":"2024-01-14T14:09:03.370557Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y8))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:08.307110Z","iopub.execute_input":"2024-01-14T14:09:08.307824Z","iopub.status.idle":"2024-01-14T14:09:08.447459Z","shell.execute_reply.started":"2024-01-14T14:09:08.307790Z","shell.execute_reply":"2024-01-14T14:09:08.446527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y9))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:14.012908Z","iopub.execute_input":"2024-01-14T14:09:14.013249Z","iopub.status.idle":"2024-01-14T14:09:14.161671Z","shell.execute_reply.started":"2024-01-14T14:09:14.013223Z","shell.execute_reply":"2024-01-14T14:09:14.160559Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spec = np.abs(librosa.stft(y10))\nmean_per_bin = np.mean(spec, axis=1)\nprint(mean_per_bin.max())\nprint(mean_per_bin.min())","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:20.801264Z","iopub.execute_input":"2024-01-14T14:09:20.801661Z","iopub.status.idle":"2024-01-14T14:09:20.977226Z","shell.execute_reply.started":"2024-01-14T14:09:20.801632Z","shell.execute_reply":"2024-01-14T14:09:20.976256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Spectrogram for Audio 1\nD1 = librosa.amplitude_to_db(np.abs(librosa.stft(y1)), ref=np.max)\n\n# Spectrogram for Audio 2\nD2 = librosa.amplitude_to_db(np.abs(librosa.stft(y2)), ref=np.max)\n\n# Create subplots\nplt.figure(figsize=(16, 4))\n\n# Plot for Audio 1\nplt.subplot(1, 2, 1)\nlibrosa.display.specshow(D1, sr=sr1, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 1')\n\n# Plot for Audio 2\nplt.subplot(1, 2, 2)\nlibrosa.display.specshow(D2, sr=sr2, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 2')\n\n# Adjust layout for better visualization\nplt.tight_layout()\n\n# Show the plot\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:28.375349Z","iopub.execute_input":"2024-01-14T14:09:28.376727Z","iopub.status.idle":"2024-01-14T14:09:30.910731Z","shell.execute_reply.started":"2024-01-14T14:09:28.376677Z","shell.execute_reply":"2024-01-14T14:09:30.909851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"D1 = librosa.amplitude_to_db(np.abs(librosa.stft(y3)), ref=np.max)\nD2 = librosa.amplitude_to_db(np.abs(librosa.stft(y4)), ref=np.max)\n\nplt.figure(figsize=(16, 4))\n\nplt.subplot(1, 2, 1)\nlibrosa.display.specshow(D1, sr=sr3, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 3')\n\nplt.subplot(1, 2, 2)\nlibrosa.display.specshow(D2, sr=sr4, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 4')\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:41.382152Z","iopub.execute_input":"2024-01-14T14:09:41.382897Z","iopub.status.idle":"2024-01-14T14:09:42.945491Z","shell.execute_reply.started":"2024-01-14T14:09:41.382863Z","shell.execute_reply":"2024-01-14T14:09:42.944545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"D1 = librosa.amplitude_to_db(np.abs(librosa.stft(y5)), ref=np.max)\nD2 = librosa.amplitude_to_db(np.abs(librosa.stft(y6)), ref=np.max)\n\nplt.figure(figsize=(16, 4))\n\nplt.subplot(1, 2, 1)\nlibrosa.display.specshow(D1, sr=sr5, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 5')\n\nplt.subplot(1, 2, 2)\nlibrosa.display.specshow(D2, sr=sr6, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 6')\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:46.815307Z","iopub.execute_input":"2024-01-14T14:09:46.816033Z","iopub.status.idle":"2024-01-14T14:09:48.662766Z","shell.execute_reply.started":"2024-01-14T14:09:46.816001Z","shell.execute_reply":"2024-01-14T14:09:48.661888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"D1 = librosa.amplitude_to_db(np.abs(librosa.stft(y7)), ref=np.max)\nD2 = librosa.amplitude_to_db(np.abs(librosa.stft(y8)), ref=np.max)\n\nplt.figure(figsize=(16, 4))\n\nplt.subplot(1, 2, 1)\nlibrosa.display.specshow(D1, sr=sr7, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 7')\n\nplt.subplot(1, 2, 2)\nlibrosa.display.specshow(D2, sr=sr8, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 8')\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:52.943260Z","iopub.execute_input":"2024-01-14T14:09:52.944069Z","iopub.status.idle":"2024-01-14T14:09:57.537145Z","shell.execute_reply.started":"2024-01-14T14:09:52.944036Z","shell.execute_reply":"2024-01-14T14:09:57.536286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"D1 = librosa.amplitude_to_db(np.abs(librosa.stft(y9)), ref=np.max)\nD2 = librosa.amplitude_to_db(np.abs(librosa.stft(y10)), ref=np.max)\n\nplt.figure(figsize=(16, 4))\n\nplt.subplot(1, 2, 1)\nlibrosa.display.specshow(D1, sr=sr9, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 9')\n\nplt.subplot(1, 2, 2)\nlibrosa.display.specshow(D2, sr=sr10, x_axis='time', y_axis='log')\nplt.colorbar(format='%+2.0f dB')\nplt.title('Spectrogram of Audio 10')\n\nplt.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:09:59.102740Z","iopub.execute_input":"2024-01-14T14:09:59.103103Z","iopub.status.idle":"2024-01-14T14:10:07.450143Z","shell.execute_reply.started":"2024-01-14T14:09:59.103074Z","shell.execute_reply":"2024-01-14T14:10:07.449286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install librosa==0.9.2","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:10:18.039445Z","iopub.execute_input":"2024-01-14T14:10:18.039810Z","iopub.status.idle":"2024-01-14T14:10:39.140613Z","shell.execute_reply.started":"2024-01-14T14:10:18.039781Z","shell.execute_reply":"2024-01-14T14:10:39.139370Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nimport audioread\nimport logging\nimport os\nimport random\nimport time\nimport warnings\n\nimport librosa\nimport numpy as np\nimport pandas as pd\nimport soundfile as sf\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.utils.data as data\n\nfrom contextlib import contextmanager\nfrom pathlib import Path\nfrom typing import Optional\n\nfrom fastprogress import progress_bar\nfrom sklearn.metrics import f1_score\nfrom torchvision import models","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:10:39.142988Z","iopub.execute_input":"2024-01-14T14:10:39.143701Z","iopub.status.idle":"2024-01-14T14:10:43.335727Z","shell.execute_reply.started":"2024-01-14T14:10:39.143659Z","shell.execute_reply":"2024-01-14T14:10:43.334925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def set_seed(seed: int = 42):\n    random.seed(seed)\n    np.random.seed(seed)\n    os.environ[\"PYTHONHASHSEED\"] = str(seed)\n    torch.manual_seed(seed)\n    torch.cuda.manual_seed(seed)  # type: ignore\n    torch.backends.cudnn.deterministic = True  # type: ignore\n    torch.backends.cudnn.benchmark = True  # type: ignore\n    \n    \ndef get_logger(out_file=None):\n    logger = logging.getLogger()\n    formatter = logging.Formatter(\"%(asctime)s - %(levelname)s - %(message)s\")\n    logger.handlers = []\n    logger.setLevel(logging.INFO)\n\n    handler = logging.StreamHandler()\n    handler.setFormatter(formatter)\n    handler.setLevel(logging.INFO)\n    logger.addHandler(handler)\n\n    if out_file is not None:\n        fh = logging.FileHandler(out_file)\n        fh.setFormatter(formatter)\n        fh.setLevel(logging.INFO)\n        logger.addHandler(fh)\n    logger.info(\"logger set up\")\n    return logger\n    \n    \n@contextmanager\ndef timer(name: str, logger: Optional[logging.Logger] = None):\n    t0 = time.time()\n    msg = f\"[{name}] start\"\n    if logger is None:\n        print(msg)\n    else:\n        logger.info(msg)\n    yield\n\n    msg = f\"[{name}] done in {time.time() - t0:.2f} s\"\n    if logger is None:\n        print(msg)\n    else:\n        logger.info(msg)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:10:51.629558Z","iopub.execute_input":"2024-01-14T14:10:51.630449Z","iopub.status.idle":"2024-01-14T14:10:51.640805Z","shell.execute_reply.started":"2024-01-14T14:10:51.630417Z","shell.execute_reply":"2024-01-14T14:10:51.639853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"logger = get_logger(\"main.log\")\nset_seed(1213)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:11:04.994530Z","iopub.execute_input":"2024-01-14T14:11:04.995408Z","iopub.status.idle":"2024-01-14T14:11:05.006192Z","shell.execute_reply.started":"2024-01-14T14:11:04.995377Z","shell.execute_reply":"2024-01-14T14:11:05.005322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"TARGET_SR = 32000\nTEST = Path(\"../input/birdsong-recognition/test_audio\").exists()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:24:35.236738Z","iopub.execute_input":"2024-01-14T14:24:35.237268Z","iopub.status.idle":"2024-01-14T14:24:35.246161Z","shell.execute_reply.started":"2024-01-14T14:24:35.237218Z","shell.execute_reply":"2024-01-14T14:24:35.244758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if TEST:\n    DATA_DIR = Path(\"../input/birdsong-recognition/\")\nelse:\n    # dataset created by @shonenkov, thanks!\n    DATA_DIR = Path(\"../input/birdcall-check/\")\n    \n\ntest = pd.read_csv(DATA_DIR / \"test.csv\")\ntest_audio = DATA_DIR / \"test_audio\"\n\n\ntest.head()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:24:39.671492Z","iopub.execute_input":"2024-01-14T14:24:39.672410Z","iopub.status.idle":"2024-01-14T14:24:39.695497Z","shell.execute_reply.started":"2024-01-14T14:24:39.672377Z","shell.execute_reply":"2024-01-14T14:24:39.694631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.read_csv(\"../input/birdsong-recognition/sample_submission.csv\")\nsub.to_csv(\"submission.csv\", index=False)  # this will be overwritten if everything goes well","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:24:40.139007Z","iopub.execute_input":"2024-01-14T14:24:40.139353Z","iopub.status.idle":"2024-01-14T14:24:40.147646Z","shell.execute_reply.started":"2024-01-14T14:24:40.139324Z","shell.execute_reply":"2024-01-14T14:24:40.146839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class ResNet(nn.Module):\n    def __init__(self, base_model_name: str, pretrained=False,\n                 num_classes=264):\n        super().__init__()\n        base_model = models.__getattribute__(base_model_name)(\n            pretrained=pretrained)\n        layers = list(base_model.children())[:-2]\n        layers.append(nn.AdaptiveMaxPool2d(1))\n        self.encoder = nn.Sequential(*layers)\n\n        in_features = base_model.fc.in_features\n\n        self.classifier = nn.Sequential(\n            nn.Linear(in_features, 1024), nn.ReLU(), nn.Dropout(p=0.2),\n            nn.Linear(1024, 1024), nn.ReLU(), nn.Dropout(p=0.2),\n            nn.Linear(1024, num_classes))\n\n    def forward(self, x):\n        batch_size = x.size(0)\n        x = self.encoder(x).view(batch_size, -1)\n        x = self.classifier(x)\n        multiclass_proba = F.softmax(x, dim=1)\n        multilabel_proba = F.sigmoid(x)\n        return {\n            \"logits\": x,\n            \"multiclass_proba\": multiclass_proba,\n            \"multilabel_proba\": multilabel_proba\n        }","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:24:40.169638Z","iopub.execute_input":"2024-01-14T14:24:40.170222Z","iopub.status.idle":"2024-01-14T14:24:40.179342Z","shell.execute_reply.started":"2024-01-14T14:24:40.170194Z","shell.execute_reply":"2024-01-14T14:24:40.178400Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_config = {\n    \"base_model_name\": \"resnet50\",\n    \"pretrained\": False,\n    \"num_classes\": 264\n}\n\nmelspectrogram_parameters = {\n    \"n_mels\": 128,\n    \"fmin\": 20,\n    \"fmax\": 16000\n}\n\nweights_path = \"/kaggle/input/birdcall-resnet50-init-weights/best.pth\"","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:24:40.798815Z","iopub.execute_input":"2024-01-14T14:24:40.799757Z","iopub.status.idle":"2024-01-14T14:24:40.804502Z","shell.execute_reply.started":"2024-01-14T14:24:40.799722Z","shell.execute_reply":"2024-01-14T14:24:40.803548Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\ndf = pd.read_csv(\"/kaggle/input/birdsong-recognition/train.csv\")\n\nunique_bird_names = df.ebird_code.unique()\nlabel_encoder = LabelEncoder()\nencoded_labels = label_encoder.fit_transform(unique_bird_names)\nBIRD_CODE = dict(zip(unique_bird_names, encoded_labels))\n\n#for bird_name, label in BIRD_CODE.items():\n#    print(f\"{bird_name}:{label}\")\n\nINV_BIRD_CODE = {v: k for k, v in BIRD_CODE.items()}\n#for bird_name, label in INV_BIRD_CODE.items():\n#    print(f\"{bird_name}:{label}\")","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:24:40.940102Z","iopub.execute_input":"2024-01-14T14:24:40.940465Z","iopub.status.idle":"2024-01-14T14:24:41.232997Z","shell.execute_reply.started":"2024-01-14T14:24:40.940435Z","shell.execute_reply":"2024-01-14T14:24:41.232219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def mono_to_color(X: np.ndarray,\n                  mean=None,\n                  std=None,\n                  norm_max=None,\n                  norm_min=None,\n                  eps=1e-6):\n    \n    # Stack X as [X,X,X]\n    X = np.stack([X, X, X], axis=-1)\n\n    # Standardize\n    mean = mean or X.mean()\n    X = X - mean\n    std = std or X.std()\n    Xstd = X / (std + eps)\n    _min, _max = Xstd.min(), Xstd.max()\n    norm_max = norm_max or _max\n    norm_min = norm_min or _min\n    if (_max - _min) > eps:\n        # Normalize to [0, 255]\n        V = Xstd\n        V[V < norm_min] = norm_min\n        V[V > norm_max] = norm_max\n        V = 255 * (V - norm_min) / (norm_max - norm_min)\n        V = V.astype(np.uint8)\n    else:\n        # Just zero\n        V = np.zeros_like(Xstd, dtype=np.uint8)\n    return V\n\n\nclass TestDataset(data.Dataset):\n    def __init__(self, df: pd.DataFrame, clip: np.ndarray,\n                 img_size=224, melspectrogram_parameters={}):\n        self.df = df\n        self.clip = clip\n        self.img_size = img_size\n        self.melspectrogram_parameters = melspectrogram_parameters\n        \n    def __len__(self):\n        return len(self.df)\n    \n    def __getitem__(self, idx: int):\n        SR = 32000\n        sample = self.df.loc[idx, :]\n        site = sample.site\n        row_id = sample.row_id\n        \n        if site == \"site_3\":\n            y = self.clip.astype(np.float32)\n            len_y = len(y)\n            start = 0\n            end = SR * 5\n            images = []\n            while len_y > start:\n                y_batch = y[start:end].astype(np.float32)\n                if len(y_batch) != (SR * 5):\n                    break\n                start = end\n                end = end + SR * 5\n                \n                melspec = librosa.feature.melspectrogram(y=y_batch,\n                                                         sr=SR,\n                                                         **self.melspectrogram_parameters)\n                melspec = librosa.power_to_db(melspec).astype(np.float32)\n                image = mono_to_color(melspec)\n                height, width, _ = image.shape\n                image = cv2.resize(image, (int(width * self.img_size / height), self.img_size))\n                image = np.moveaxis(image, 2, 0)\n                image = (image / 255.0).astype(np.float32)\n                images.append(image)\n            images = np.asarray(images)\n            return images, row_id, site\n        else:\n            end_seconds = int(sample.seconds)\n            start_seconds = int(end_seconds - 5)\n            \n            start_index = SR * start_seconds\n            end_index = SR * end_seconds\n            \n            y = self.clip[start_index:end_index].astype(np.float32)\n\n            melspec = librosa.feature.melspectrogram(y=y, sr=SR, **self.melspectrogram_parameters)\n            melspec = librosa.power_to_db(melspec).astype(np.float32)\n\n            image = mono_to_color(melspec)\n            height, width, _ = image.shape\n            image = cv2.resize(image, (int(width * self.img_size / height), self.img_size))\n            image = np.moveaxis(image, 2, 0)\n            image = (image / 255.0).astype(np.float32)\n\n            return image, row_id, site","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:41:22.850522Z","iopub.execute_input":"2024-01-14T14:41:22.851242Z","iopub.status.idle":"2024-01-14T14:41:22.870234Z","shell.execute_reply.started":"2024-01-14T14:41:22.851208Z","shell.execute_reply":"2024-01-14T14:41:22.869305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_model(config: dict, weights_path: str):\n    model = ResNet(**config)\n    checkpoint = torch.load(weights_path)\n    model.load_state_dict(checkpoint[\"model_state_dict\"])\n    device = torch.device(\"cuda\")\n    model.to(device)\n    model.eval()\n    return model","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:41:23.260286Z","iopub.execute_input":"2024-01-14T14:41:23.260695Z","iopub.status.idle":"2024-01-14T14:41:23.267058Z","shell.execute_reply.started":"2024-01-14T14:41:23.260662Z","shell.execute_reply":"2024-01-14T14:41:23.265870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def prediction_for_clip(test_df: pd.DataFrame, \n                        clip: np.ndarray, \n                        model: ResNet, \n                        mel_params: dict, \n                        threshold=0.5):\n\n    dataset = TestDataset(df=test_df, \n                          clip=clip,\n                          img_size=224,\n                          melspectrogram_parameters=mel_params)\n    loader = data.DataLoader(dataset, batch_size=1, shuffle=False)\n    device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n    \n    model.eval()\n    prediction_dict = {}\n    for image, row_id, site in progress_bar(loader):\n        site = site[0]\n        row_id = row_id[0]\n        if site in {\"site_1\", \"site_2\"}:\n            image = image.to(device)\n\n            with torch.no_grad():\n                prediction = model(image)\n                proba = prediction[\"multilabel_proba\"].detach().cpu().numpy().reshape(-1)\n\n            events = proba >= threshold\n            labels = np.argwhere(events).reshape(-1).tolist()\n\n        else:\n            # to avoid prediction on large batch\n            image = image.squeeze(0)\n            batch_size = 16\n            whole_size = image.size(0)\n            if whole_size % batch_size == 0:\n                n_iter = whole_size // batch_size\n            else:\n                n_iter = whole_size // batch_size + 1\n                \n            all_events = set()\n            for batch_i in range(n_iter):\n                batch = image[batch_i * batch_size:(batch_i + 1) * batch_size]\n                if batch.ndim == 3:\n                    batch = batch.unsqueeze(0)\n\n                batch = batch.to(device)\n                with torch.no_grad():\n                    prediction = model(batch)\n                    proba = prediction[\"multilabel_proba\"].detach().cpu().numpy()\n                    \n                events = proba >= threshold\n                for i in range(len(events)):\n                    event = events[i, :]\n                    labels = np.argwhere(event).reshape(-1).tolist()\n                    for label in labels:\n                        all_events.add(label)\n                        \n            labels = list(all_events)\n        if len(labels) == 0:\n            prediction_dict[row_id] = \"nocall\"\n        else:\n            labels_str_list = list(map(lambda x: INV_BIRD_CODE[x], labels))\n            label_string = \" \".join(labels_str_list)\n            prediction_dict[row_id] = label_string\n    return prediction_dict","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:41:23.784248Z","iopub.execute_input":"2024-01-14T14:41:23.784889Z","iopub.status.idle":"2024-01-14T14:41:23.799617Z","shell.execute_reply.started":"2024-01-14T14:41:23.784857Z","shell.execute_reply":"2024-01-14T14:41:23.798755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def prediction(test_df: pd.DataFrame,\n               test_audio: Path,\n               model_config: dict,\n               mel_params: dict,\n               weights_path: str,\n               threshold=0.5):\n    model = get_model(model_config, weights_path)\n    unique_audio_id = test_df.audio_id.unique()\n\n    warnings.filterwarnings(\"ignore\")\n    prediction_dfs = []\n    for audio_id in unique_audio_id:\n        with timer(f\"Loading {audio_id}\", logger):\n            clip, _ = librosa.load(test_audio / (audio_id + \".mp3\"),\n                                   sr=TARGET_SR,\n                                   mono=True)\n        \n        test_df_for_audio_id = test_df.query(\n            f\"audio_id == '{audio_id}'\").reset_index(drop=True)\n        with timer(f\"Prediction on {audio_id}\", logger):\n            prediction_dict = prediction_for_clip(test_df_for_audio_id,\n                                                  clip=clip,\n                                                  model=model,\n                                                  mel_params=mel_params,\n                                                  threshold=threshold)\n        row_id = list(prediction_dict.keys())\n        birds = list(prediction_dict.values())\n        prediction_df = pd.DataFrame({\n            \"row_id\": row_id,\n            \"birds\": birds\n        })\n        prediction_dfs.append(prediction_df)\n    \n    prediction_df = pd.concat(prediction_dfs, axis=0, sort=False).reset_index(drop=True)\n    return prediction_df","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:41:24.489214Z","iopub.execute_input":"2024-01-14T14:41:24.489566Z","iopub.status.idle":"2024-01-14T14:41:24.499089Z","shell.execute_reply.started":"2024-01-14T14:41:24.489538Z","shell.execute_reply":"2024-01-14T14:41:24.498208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = prediction(test_df=test,\n                        test_audio=test_audio,\n                        model_config=model_config,\n                        mel_params=melspectrogram_parameters,\n                        weights_path=weights_path,\n                        threshold=0.8)\nsubmission.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:41:25.513759Z","iopub.execute_input":"2024-01-14T14:41:25.514129Z","iopub.status.idle":"2024-01-14T14:41:44.080225Z","shell.execute_reply.started":"2024-01-14T14:41:25.514100Z","shell.execute_reply":"2024-01-14T14:41:44.078836Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:41:44.083189Z","iopub.execute_input":"2024-01-14T14:41:44.084047Z","iopub.status.idle":"2024-01-14T14:41:44.101607Z","shell.execute_reply.started":"2024-01-14T14:41:44.083998Z","shell.execute_reply":"2024-01-14T14:41:44.100209Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.row_id.unique()","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:41:44.103740Z","iopub.execute_input":"2024-01-14T14:41:44.104657Z","iopub.status.idle":"2024-01-14T14:41:44.115708Z","shell.execute_reply.started":"2024-01-14T14:41:44.104607Z","shell.execute_reply":"2024-01-14T14:41:44.114510Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv(\"/kaggle/working/submission.csv\")\n\n# Remove trailing numbers and duplicates from 'row_id' column\ndata['row_id'] = data['row_id'].replace(to_replace=r'_[0-9]+$', value='', regex=True)\ndata = data.drop_duplicates()\nrows = data[data.duplicated(subset=['row_id'], keep=False) & (data['birds'] == 'nocall')]\ndf_no_duplicates = data.drop(rows.index)\n\ndf_no_duplicates = df_no_duplicates.reset_index(drop=True)\n\ndf_no_duplicates","metadata":{"execution":{"iopub.status.busy":"2024-01-14T14:41:44.118257Z","iopub.execute_input":"2024-01-14T14:41:44.118658Z","iopub.status.idle":"2024-01-14T14:41:44.147938Z","shell.execute_reply.started":"2024-01-14T14:41:44.118620Z","shell.execute_reply":"2024-01-14T14:41:44.146816Z"},"trusted":true},"execution_count":null,"outputs":[]}]}