{"cells":[{"metadata":{},"cell_type":"markdown","source":"## [Birdcall Identification] EDA with Visualization\n\nThe current data is a very EDA pleasant situation dealing with voice data, geography data, date data, text data, and structured data. (This information can later be used for pseudo labeling, etc.)\n\nLet's take a look at the overall flow.","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Setting for EDA\n\nIf you are curious about my environment, you can also check the settings.","execution_count":null},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport folium\nfrom folium import plugins\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nimport missingno as msno\n\nimport os","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"# version check \n\nprint(f'numpy : {np.__version__}')\nprint(f'pandas : {pd.__version__}')\nprint(f'matplotlib : {mpl.__version__}')\nprint(f'folium : {folium.__version__}')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"# configuration for notebook\n\npd.options.display.max_columns = 40  ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Data Load & Feature Check","execution_count":null},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"PATH = '/kaggle/input/birdsong-recognition/'\ntrain = pd.read_csv(f'{PATH}/train.csv')\ntest = pd.read_csv(f'{PATH}/test.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(train.shape)\ntrain.head(3)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"msno.matrix(train)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## [ebird_type, species] Distribution : Bird Type","execution_count":null},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"fig, ax = plt.subplots(1, 1, figsize=(20, 5), dpi=200)\nebird_code = train['ebird_code'].value_counts()\nax.bar(ebird_code.index, ebird_code, color='#6EB5FF')\n\nax.text(134, 105, \n        '100 samples for 134 birsds',)\n\n\nax.text(235, 120,\n        f\"mean : {ebird_code.mean():.2f} std: {ebird_code.std():.2f}\",\n        color=\"black\", fontsize=11, fontweight='bold',\n         bbox=dict(boxstyle='round', pad=0.3, color='lightgray')\n)\n\nax.set_ylim(0, 130)\nax.set_xticks([])\nax.margins(0.01, 0.01)\n\nax.set_title('Distribution : bird type', \n             fontsize=15, fontweight='bold', fontfamily='serif',\n             x=0.075, y=1.04,)\n\n\n\nplt.tight_layout()\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"There are many birds with 100 data, but there is definitely little data.","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## [latitude, longitude] Check Location by Cluster\n\nSince there is latitude and longitude information obtained from new data, you can get some information about the distribution of birds by drawing it as a heat map or cluster.\n\nProbably using text information would be a better structured dataset, but I hope someone else will make it.","execution_count":null},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"train['latitude'] = train['latitude'].apply(lambda x : float(x) if '.' in x else None)\ntrain['longitude'] = train['longitude'].apply(lambda x : float(x) if '.' in x else None)\n\ntry : \n    train.drop(['license', 'file_type'], inplace=True)\nexcept :\n    pass","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"m = folium.Map()\n\ntrain_for_map = train[['latitude', 'longitude', 'species']].dropna()\n\n# Marker Cluster\nplugins.MarkerCluster(train_for_map[['latitude', 'longitude']].values,\n                      list(train_for_map['species'].apply(str).values)\n).add_to(m)\n\n# Mouse Check\nformatter = \"function(num) {return L.Util.formatNum(num, 3) + ' º ';};\"\nplugins.MousePosition(\n    position='topright',\n    separator=' | ',\n    empty_string='NaN',\n    lng_first=True,\n    num_digits=20,\n    prefix='Coordinates:',\n    lat_formatter=formatter,\n    lng_formatter=formatter,\n).add_to(m)\n\n# minimap\nminimap = plugins.MiniMap()\nm.add_child(minimap)\n\n\nm\n\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"You can see the most in the United States and then the most in Europe.","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}