{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# <span style=\"color:#6D72C3;\">**Phoenix — the cleansing flame is eternal, dying to be reborn.**<span>\n    \n### <span style=\"color:#6D72C3;\">**Table of content**<span>\n<a id=\"table-of-contents\"></a>\n- [1. Introduction](#1)\n- [2. Dataset Overview](#2)\n    - [2.1 Train Dataset](#2.1)\n        - [2.1.1 Quick view](#2.1.1)\n        - [2.1.2 Data types](#2.1.2)\n        - [2.1.3 Basic Statistics](#2.1.3)\n        - [2.1.4 Target Column](#2.1.4)\n    - [2.2 Test Dataset](#2.2)\n        - [2.2.1 Quick view](#2.2.1)\n        - [2.2.2 Data types](#2.2.2)\n    - [2.3 Ebird Dataset](#2.3)\n       - [2.3.1 Quick view](#2.3.1)\n       - [2.3.2 Data types](#2.3.2)\n- [3. Explore Data Analisys](#3)","metadata":{}},{"cell_type":"code","source":"\nimport pandas as pd\nimport numpy as np\nimport seaborn as sns\nfrom matplotlib import pyplot as plt\n\nimport librosa\nimport librosa.display\nimport IPython.display as ipd\n\n\nBASE_DIR = '../input/birdclef-2022/'\ntrain = pd.read_csv(f'{BASE_DIR}/train_metadata.csv')\ntest = pd.read_csv(f'{BASE_DIR}/test.csv')\nebird = pd.read_csv(f'{BASE_DIR}/eBird_Taxonomy_v2021.csv')\nss = pd.read_csv(f'{BASE_DIR}/sample_submission.csv')\n\nimport warnings\nwarnings.filterwarnings('ignore')\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-30T23:26:50.640861Z","iopub.execute_input":"2022-03-30T23:26:50.641349Z","iopub.status.idle":"2022-03-30T23:26:50.768201Z","shell.execute_reply.started":"2022-03-30T23:26:50.641315Z","shell.execute_reply":"2022-03-30T23:26:50.767635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"1\"></a>\n# <span style=\"color:#6D72C3;\">**Introduction**<span>\n\n<span style=\"color:#514F59;\">As the “extinction capital of the world,” Hawai'i has lost 68% of its bird species, the consequences of which can harm entire food chains. Researchers use population monitoring to understand how native birds react to changes in the environment and conservation efforts. But many of the remaining birds across the islands are isolated in difficult-to-access, high-elevation habitats. With physical monitoring difficult, scientists have turned to sound recordings. Known as bioacoustic monitoring, this approach could provide a passive, low labor, and cost-effective strategy for studying endangered bird populations.<span>\n\n<span style=\"color:#514F59;\">In this competition, you’ll use your machine learning skills to identify bird species by sound. Specifically, you'll develop a model that can process continuous audio data and then acoustically recognize the species. The best entries will be able to train reliable classifiers with limited training data.<span>\n\n## <span style=\"color:#6D72C3;\">**Evaluation**<span>\n\n$ \\text{Macro-F1} = \\frac{1}{Q} \\sum_{Q}^{j=1} \\frac{2 \\times pj \\times rj}{pj + rj}$","metadata":{}},{"cell_type":"code","source":"\"\"\"\n                                            TORCH ME\n                                           UPVOTE IT :)\n\n:::::::::::::::::::::~?YY7!::~~^^^^!7?JJJJJJJJJJJJJJJJJJJJJ?????YGG5J??5PPPGGGGGGGGGGGGGGG5PGGP55PBB\n.....................^?JJ?P5?~^^^~7?????????????????????JJJJJ??JGGG5???7?5PPPGGGGGGGGGBBBGPGBGG555GB\n.....................^?JY?PGGPJ~~7???????????????????????????JJPBGBY??????JPGGGGGGGGB#GGPBGGGPBBPPGB\n..:::::::............^?YJ?5GGG5^7???????JJJJJJJJJJJJJJ?????????PBBGY???????75GGGGGGB##P5YYG55YB#BGBB\n:::::::::::::........^?J~~Y5GG!~??JJJ?????????????????JJJJJJJ??5BGY5JJ??????75GGGGGGBBBBBBBBBBBP5PGG\n::::::::::::::.......^?~^!!!Y?:?J????????????????????????????Y?JGJ?J??JJ?????75GGGGGPPGGGGGP5YJ?????\n::::::::::::::.......~~^~:^~:.~J?????????????????????????????JJ??JJJJJ?JJ?????7PGP5PGGGGGGP5YYJJ???7\n::::::::::::::.......~^!~^^~~^???J???????J????????JJ????????J?JJJJ???JJJJY??????GPPGGGPPPPPP5YYYJJJJ\n:::::::::::::.......:^:~^^^^~~!?Y?J?????JJ????????YJ??????JJYJ?J????????JYY?????5PP555555PPGGPPPPPPP\n:::::::::::.........^:^:^^^^^^!JYJY?????Y????????JJJ??????YYYJ????????????J?????JPPPPPP555PPPGPPPPPG\n....................^::^^^~^^^7YJYY?????Y???????J??J?????JYJJ?J???????????JJ?????YPPPPPPPPPPPPP55PP5\n...................:^.::^^!^^~?JJJJ????JJ???????J7?J??YJ?YYJJ?JJ???JJJ?????Y?????JPP555555555PPPGGPP\n...................^:::::~~^^??YJYY????YY????J?J?7?J??5JJJJJYJJYJ??JYJ?????Y??????PGGGGGGGGGGGGBBBBB\n...................~^~^^^!^^777YJ?J????YY???YJJ?77?J?J5JY?JJ?77?Y???YY?????Y??????YGGBBBBBBBBBBBBBBB\n...................^^!^^^!^!~.~JY?JJ???YY??J5?J777?J?YYJYY55JJ?7?Y??JY?????Y??????JGBBBBBBBBBBBBBBBB\n:::::::::::........~~!^^~!~~:~?5GGGGP5YYY??J5JJ777?JJJPGGB#BBBP5YYY?JY?????Y???????PBBBBBBBBBBBBBBBB\n??????????????????J!~!^^!!!7!~!YGGGGG55Y???????777?77?J7JPPPPPPJJJ5PJY????JY???????YBGBBBBBBBBBBBBBB\n777777777777777777?!^7^^7!~?^.^?J5G5PJ!7777777777777777!!J5PYYPJ!7JPYY????JY???????JGGBBBBBBBBBBBBBB\n..................^~^7^^?^:~!~~7JJ??5J777777?77777777777YY?77YPJJYY??J????JYJJ??????PBBBBBBBBBBBBBBB\n..................~~^7^^J^:::^^?5J??J?777777?77777777777?JJYJYY???77?J????YY?YJ?????5G55PGBBBBBBBBBB\n::::::::::::......~^^7~^?!:::::!777777777777?77777777777777777777777?Y????YJ?YJ?????YYJYYY5GBBBBBBBB\n:::::::::::::::...~^^!~^??:::::^777777777777?77777777777777777777777?Y????Y??J??????JYYJJYYGBBBBBBB#\n:::::::::::::::...!^^~!^?J!:::::!77777777777777777777777777777777777?Y???JY?J????????YYJJYYBBBBBBB##\n:::::::::::::::...!^^^7^???^::::~777777777777?????777777777777777777?Y???JYJ?????????YYYJJY5GBBBB###\n::::::::::::::::.:!^^^7^?Y?7:::::77777777????????JJJY?77777777777777?Y???YY??????????JYJJYYJJPBBB###\n::::::::::::::::..!7^^!~7YJJ~::::~7777775GPPPGGGGGGBBB5??7777777777?JY???YJ?????JJ????YYJJJJJJYPB###\n::::::::::::::::..!7^^!!7Y?JJ^::::!7777?PBB#BBGGGGGGBBBJ?777777777?YYY???YJ?????JY????Y5JJJJJJJJP###\n::::::::::::::....77^^~7!Y???7:.:::!7777YBGP5YYYYYYY55P??77777777?YJJY???YJ??????YJ???JYJJJJJJJJJPB#\n::::::::::::......7!^^~!!YJ????~:::^7777?P5YYYYYYYYYY5J77777777?JYJ?JY??JY???????JY????YJJJJJJJJJJPB\n:::::::::.........!~^~~!~YJ???YJ7!^:^!777?JYYYYYYY5YJ?7777777?JYJ???JY??JY????????YY???YJJJJJJJJJJYJ\n..................~~^~~!~YJ??JY??J?7!~~7777???JJJJ??77777??JJJYYJ???YY??JY?????????YY??JYJJJJJJJYJ??\n..................!^^!~7~JJ??JY??Y??JJJ7!777777777777???JJ????J7Y???JY??YY??????????YJ?JYJJJJJYJ????\n.................:!^!?^!~JJ??JJ??YJ??JY???777?777???JJ???77??J77JJ??JY??Y5??????JJ??JYJ?YJJJJ???????\n.................^~^!!~7~JY??JJ??JY??JYY?7?????JJJJ??777????7777?JJ?JY??Y5Y?????JYJ?JJ5JYYJ?????????\n.................~~~~!~7^?Y??JJ???YJ?JY?????77???77???J???77777777?JYY??YJYJ???JJJYJJJJ5YY?????JJYYY\n.................!^!.!~7~?Y??JYJJJY5YY5777????777????777777777777777?Y??5YY5JJJJJJJYJJJJY5???JPGBBBB\n^~~~^^^~~~^^^^^^!!~7^7~!~?YJ??JJY555YYY777777J?7?J777777777777777777Y5?J555555YYYJJJ5JJJJ5Y?JGBBBBBB\n5555555555555555Y~?YYYJ?~??!~~~JYY55YY?7777777J?J7777777777777777777Y5?JP555555YYYYY5555YJYY5BGGGGGB\n555555555555555?7!!~~?5J~J?^~!YY!7YYJ?77777777?YJ7777777777777777777?YJJP5YY5555YYYYY55555555PPPGGGB\nGGGGGGGG555555Y~^^^~!YJ7!J?^^~77!!!777777777777J777777777777777777777YJJ5Y55555YYYYYY5P5Y55555555PGB\nGGGGGGG5555555J~~~~^7?77!J7~!7~^::.~7777777777J5J77777777777777777777YJYJ7?JY5P55YYY55P55P555555PBBB\nGGGGGGP55555557~~~~~~!!?!J55PJ::::::^!7777777?PPPY7777777777777777777YJYJ777?G#BBGGPP55555555555BBBB\nBBBBBB555555557~~~J5PPP57YGPP7:::::::^!7777775PPPPY777777777777777777YJYJ7??JB#######BPPBGGP555GBBBB\nBB#BBG555555557~~?GGGGG5?5GPP7:::::::::~!777YPPPPPPY77777777777777777JYYJ???5########BPG####P5PBB#B#\nBBBBBP555555557~~YGGGGGPJPGPP!::::::::::^~!JPPPPPPPPY77777777777777??JYYJ???G########BPB####PPG#B###\nBBBB#P555555557~~5GGGGGGJPGPG7:::::::::::::755PPPPPP5?77777777777?????5YJ??Y#########GP#####PPB#####\nBBBBB555555555?~~5GGGGGGYGGPG?::::::::::::::^JPPPPPY?7777777??????????5YY?JP#########GB#####PG######\n                        #E5D4ED   #6D72C3   #5941A9   #514F59   #1D1128\n\"\"\";","metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:46.393797Z","iopub.execute_input":"2022-03-30T23:21:46.394027Z","iopub.status.idle":"2022-03-30T23:21:46.404709Z","shell.execute_reply.started":"2022-03-30T23:21:46.393998Z","shell.execute_reply":"2022-03-30T23:21:46.403507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2\"></a>\n\n# <span style=\"color:#6D72C3;\">**Dataset Overview**<span>\n[back to top](#table-of-contents)\n<a id=\"2.1\"></a>\n\n## <span style=\"color:#6D72C3;\">**Train Dataset**<span>\n\n|Variable|Definition|\n|---|---|\n| primary label | A code for the bird species. You can review detailed information about the bird codes by appending the code to `https://ebird.org/species/`. ||\n| secondary labels |  Background species as annotated by the recordist. An empty list does not mean that no background birds are audible. ||\n| type | type of bird sound ||\n| latitude | - ||\n| longitude | - ||\n| scientific name | - ||\n| common name | - ||\n| autor | The eBird user who provided the recording. ||\n| license | - ||\n| ratin | Float value between 0.0 and 5.0 as an indicator of the quality rating on Xeno-canto and the number of background species, ||\n| | where 5.0 is the highest and 1.0 is the lowest. 0.0 means that this recording has no user rating yet. ||\n| time | - ||\n| url | - ||\n| filename | The associated audio file. ||","metadata":{}},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.1.1\"></a>\n\n### <span style=\"color:#6D72C3;\">**Quick view**<span>","metadata":{}},{"cell_type":"code","source":"train.head(3)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:46.406089Z","iopub.execute_input":"2022-03-30T23:21:46.406342Z","iopub.status.idle":"2022-03-30T23:21:46.446737Z","shell.execute_reply.started":"2022-03-30T23:21:46.406304Z","shell.execute_reply":"2022-03-30T23:21:46.445864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'Number of rows: {train.shape[0]}; Number of columns: {train.shape[1]}; No of missing values: {sum(train.isna().sum())}')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:46.448632Z","iopub.execute_input":"2022-03-30T23:21:46.448878Z","iopub.status.idle":"2022-03-30T23:21:46.473953Z","shell.execute_reply.started":"2022-03-30T23:21:46.448848Z","shell.execute_reply":"2022-03-30T23:21:46.473004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.1.2\"></a>\n\n### <span style=\"color:#6D72C3;\">**Data types**<span>","metadata":{}},{"cell_type":"code","source":"train.dtypes","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:46.475424Z","iopub.execute_input":"2022-03-30T23:21:46.476496Z","iopub.status.idle":"2022-03-30T23:21:46.485738Z","shell.execute_reply.started":"2022-03-30T23:21:46.476450Z","shell.execute_reply":"2022-03-30T23:21:46.484514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.1.3\"></a>\n\n### <span style=\"color:#6D72C3;\">**Basic statistics**<span>","metadata":{}},{"cell_type":"code","source":"train.describe()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:46.488161Z","iopub.execute_input":"2022-03-30T23:21:46.489201Z","iopub.status.idle":"2022-03-30T23:21:46.525822Z","shell.execute_reply.started":"2022-03-30T23:21:46.489162Z","shell.execute_reply":"2022-03-30T23:21:46.524855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.1.4\"></a>\n\n### <span style=\"color:#6D72C3;\">**Target columns**<span>","metadata":{}},{"cell_type":"code","source":"print('Frequency of each target classes:')\ntrain['primary_label'].value_counts()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:46.876607Z","iopub.execute_input":"2022-03-30T23:21:46.876894Z","iopub.status.idle":"2022-03-30T23:21:46.887858Z","shell.execute_reply.started":"2022-03-30T23:21:46.876866Z","shell.execute_reply":"2022-03-30T23:21:46.887324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.2\"></a>\n\n## <span style=\"color:#6D72C3;\">**Test Dataset**<span>\n\n|Variable|Definition|\n|---|---|\n| row id | A unique identifier for the row. ||\n| file_id | A unique identifier for the audio file. ||\n| bird | The ebird code for the row. There is one row for each of the scored species per 5 second window per audio file. ||\n| end_time | The last second of the 5 second time window (5, 10, 15, etc). ||\n","metadata":{}},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.2.1\"></a>\n\n### <span style=\"color:#6D72C3;\">**Quick view**<span>","metadata":{}},{"cell_type":"code","source":"test","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:47.385372Z","iopub.execute_input":"2022-03-30T23:21:47.385985Z","iopub.status.idle":"2022-03-30T23:21:47.396569Z","shell.execute_reply.started":"2022-03-30T23:21:47.385937Z","shell.execute_reply":"2022-03-30T23:21:47.395785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.2.2\"></a>\n\n### <span style=\"color:#6D72C3;\">**Data types**<span>","metadata":{}},{"cell_type":"code","source":"test.dtypes","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:47.886075Z","iopub.execute_input":"2022-03-30T23:21:47.886452Z","iopub.status.idle":"2022-03-30T23:21:47.894252Z","shell.execute_reply.started":"2022-03-30T23:21:47.886412Z","shell.execute_reply":"2022-03-30T23:21:47.893458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.3\"></a>\n\n## <span style=\"color:#6D72C3;\">**Ebird DataSet**<span>\n\n[back to top](#table-of-contents)\n<a id=\"2.3.1\"></a>\n\n### <span style=\"color:#6D72C3;\">**Quick view**<span>","metadata":{}},{"cell_type":"code","source":"ebird.head(10)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:48.417061Z","iopub.execute_input":"2022-03-30T23:21:48.417798Z","iopub.status.idle":"2022-03-30T23:21:48.433407Z","shell.execute_reply.started":"2022-03-30T23:21:48.417755Z","shell.execute_reply":"2022-03-30T23:21:48.432808Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'Number of rows: {ebird.shape[0]}; Number of columns: {ebird.shape[1]}; No of missing values: {sum(ebird.isna().sum())}')","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:48.988001Z","iopub.execute_input":"2022-03-30T23:21:48.988308Z","iopub.status.idle":"2022-03-30T23:21:49.008775Z","shell.execute_reply.started":"2022-03-30T23:21:48.988257Z","shell.execute_reply":"2022-03-30T23:21:49.007566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"2.3.2\"></a>\n\n### <span style=\"color:#6D72C3;\">**Data types**<span>","metadata":{}},{"cell_type":"code","source":"ebird.dtypes","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:21:49.511319Z","iopub.execute_input":"2022-03-30T23:21:49.511937Z","iopub.status.idle":"2022-03-30T23:21:49.519142Z","shell.execute_reply.started":"2022-03-30T23:21:49.511899Z","shell.execute_reply":"2022-03-30T23:21:49.518355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"[back to top](#table-of-contents)\n<a id=\"3\"></a>\n\n# <span style=\"color:#6D72C3;\">**Exploratory Data Analysis**<span>","metadata":{}},{"cell_type":"code","source":"#ref https://www.kaggle.com/code/m1y7k8/birdclef-2022-eda/notebook#When-are-birds-singing?%E2%8C%9A\nimport geopandas as gpd\nfacecolor = '#1D1128'\n\n# initialize an axis\nfig, ax = plt.subplots(figsize=(26,20), facecolor=facecolor)\n# plot map on axis\ncountries = gpd.read_file(gpd.datasets.get_path(\"naturalearth_lowres\"))\ncountries.plot(color=\"lightgrey\", ax=ax)\n\nax.set_facecolor(facecolor)\nfor s in [\"top\",\"right\", \"left\", \"bottom\"]:\n    ax.spines[s].set_visible(False)\n\n# plot points\ncmap = plt.cm.get_cmap('jet')\nbirds = len(train[\"primary_label\"].unique())\nfor i, (bird, dfg) in enumerate(train.groupby(\"primary_label\")):\n    dfg.longitude = np.around(dfg.longitude, 1)\n    dfg.latitude = np.around(dfg.latitude, 1)\n    dfgg = dfg.groupby([\"longitude\", \"latitude\"]).size().reset_index(name=\"counts\")\n    dfgg.plot(x=\"longitude\", y=\"latitude\", kind=\"scatter\", ax=ax, label=bird, alpha=0.5, color='#6D72C3')\n\nax.legend(loc='upper center', bbox_to_anchor=(0.5, 1.25), ncol=15, fancybox=True, shadow=False, facecolor=facecolor, edgecolor=facecolor, labelcolor='#E5D4ED')\n# get axes limits\nx_lo, x_up = ax.get_xlim()\ny_lo, y_up = ax.get_ylim()\n# add minor ticks with a specified sapcing (deg)\ndeg = 5\n# add grid\nax.set_xticks(np.arange(np.ceil(x_lo), np.ceil(x_up), deg), minor=True)\nax.set_yticks(np.arange(np.ceil(y_lo), np.ceil(y_up), deg), minor=True)\nax.grid(which='major', axis='y', zorder=0, color='#E5D4ED', linewidth=0.4, alpha=0.3)\nax.grid(which='major', axis='x', zorder=0, color='#E5D4ED', linewidth=0.4, alpha=0.3)\nplt.text(-70, 145, 'Geo Scatter Map of Bird Types', color='#E5D4ED', fontsize=36, fontweight='bold');\nplt.text(-70.5, 145.5, 'Geo Scatter Map of Bird Types', color='#E5D4ED', fontsize=36, fontweight='bold');\nplt.text(-71, 146, 'Geo Scatter Map of Bird Types', color='#6D72C3', fontsize=36, fontweight='bold');\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:29:15.891210Z","iopub.execute_input":"2022-03-30T23:29:15.891587Z","iopub.status.idle":"2022-03-30T23:29:34.067199Z","shell.execute_reply.started":"2022-03-30T23:29:15.891543Z","shell.execute_reply":"2022-03-30T23:29:34.066033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def formatter(v):\n    if type(v) is str:\n        return v\n    if pd.isna(v) or v <= 0:\n        return ''\n    if v == int(v):\n        return f'{v:.0f}'\n    return f'{v:.3f}'\n#author\nfig = plt.figure(figsize=(20, 8), facecolor='#1D1128')\ngs = fig.add_gridspec(1, 2)\nbackground_color = '#1D1128'\ngs.update(wspace=0.2, hspace=0.5)\nrun_no = 0\nfor row in range(0, 1):\n    for col in range(0, 2):\n        locals()[\"ax\"+str(run_no)] = fig.add_subplot(gs[row, col])\n        locals()[\"ax\"+str(run_no)].set_facecolor(background_color)\n        for s in [\"top\",\"right\", 'bottom', 'left']:\n            locals()[\"ax\"+str(run_no)].spines[s].set_visible(False)\n        run_no += 1  \n_ = train['primary_label'].value_counts(ascending=True, normalize=True)[:25] * 100\nax0.barh(_.index, _.values, color=['#6D72C3' for col in range(25)])\nax0.tick_params(axis='y', colors=\"#E5D4ED\")\nfor ind, val in enumerate(_):\n        #print(val)\n        ax0.text(val-0.006, ind, formatter(val), fontweight=\"bold\", color='#E5D4ED', fontsize=14)\n\n_ = train['scientific_name'].value_counts(ascending=True, normalize=True)[:25] * 100\nax1.barh(_.index, _.values, color=['#6D72C3' for col in range(25)])\nax1.tick_params(axis='y', colors=\"#E5D4ED\", width=2)\nfor ind, val in enumerate(_):\n        #print(val)\n        ax1.text(val-0.006, ind, formatter(val), fontweight=\"bold\", color='#E5D4ED', fontsize=14)\n\nplt.text(-0.05, 27, 'Most Common Classes', color='#E5D4ED', fontsize=36, fontweight='bold');\nplt.text(-0.0505, 27.1, 'Most Common Classes', color='#E5D4ED', fontsize=36, fontweight='bold');\nplt.text(-0.051, 27.2, 'Most Common Classes', color='#6D72C3', fontsize=36, fontweight='bold');\n","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-30T23:22:37.475695Z","iopub.execute_input":"2022-03-30T23:22:37.476014Z","iopub.status.idle":"2022-03-30T23:22:38.517194Z","shell.execute_reply.started":"2022-03-30T23:22:37.475981Z","shell.execute_reply":"2022-03-30T23:22:38.516519Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# IN PROCESS\n\n:( went to bed","metadata":{}}]}