{"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":"# What a problem?","metadata":{}},{"cell_type":"markdown","source":"I see in kernels some whale vs dolphin distribution ([one](https://www.kaggle.com/lokesharya99/happy-whale-and-dolphin-an-eda), [two](https://www.kaggle.com/gpreda/happy-whales-and-dolphins)). All of them are wrong :( The truth is: if specie has `_whale` in name, it doesn't mean it is the whale! ","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"markdown","source":"# Who is who?","metadata":{}},{"cell_type":"markdown","source":"So, good news: all `_dolphin` are dolphins, `beluga` is whale, but some whales are dolphins too: `false_killer_whale`, `killer_whale`, `pygmy_killer_whale`, `long_finned_pilot_whale`, `short_finned_pilot_whale`, and `melon_headed_whale`. \n\nSo, at total **10 whales and 16 dolphins species**.\n\nSee details about species in my previous [kernel](https://www.kaggle.com/kwentar/what-about-species)","metadata":{}},{"cell_type":"markdown","source":"# Correct distributions:","metadata":{}},{"cell_type":"code","source":"import pandas as pd\ntrain_df = pd.read_csv('../input/happy-whale-and-dolphin/train.csv')\ntrain_df.species.replace({\"globis\": \"short_finned_pilot_whale\",\n                          \"pilot_whale\": \"short_finned_pilot_whale\",\n                          \"kiler_whale\": \"killer_whale\",\n                          \"bottlenose_dolpin\": \"bottlenose_dolphin\"}, inplace=True)\n","metadata":{"execution":{"iopub.status.busy":"2022-02-06T20:06:23.147507Z","iopub.execute_input":"2022-02-06T20:06:23.148574Z","iopub.status.idle":"2022-02-06T20:06:23.303037Z","shell.execute_reply.started":"2022-02-06T20:06:23.148457Z","shell.execute_reply":"2022-02-06T20:06:23.302281Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"whale_species = ['humpback_whale', 'beluga', 'blue_whale', 'fin_whale', 'southern_right_whale',\n                'gray_whale', 'minke_whale', 'cuviers_beaked_whale', 'sei_whale', 'brydes_whale']\n\ntrain_df['whale_dolphin'] = ['whale' if x in whale_species else 'dolphin' for x in train_df.species]\ntrain_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-06T20:10:38.030533Z","iopub.execute_input":"2022-02-06T20:10:38.030818Z","iopub.status.idle":"2022-02-06T20:10:38.060327Z","shell.execute_reply.started":"2022-02-06T20:10:38.030784Z","shell.execute_reply":"2022-02-06T20:10:38.059742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nprint(train_df.whale_dolphin.value_counts())\nfig = px.pie(train_df.whale_dolphin, \n             values=train_df.whale_dolphin.value_counts().values, \n             names=train_df.whale_dolphin.value_counts().index)\nfig.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-02-06T20:15:36.884610Z","iopub.execute_input":"2022-02-06T20:15:36.884900Z","iopub.status.idle":"2022-02-06T20:15:36.957258Z","shell.execute_reply.started":"2022-02-06T20:15:36.884869Z","shell.execute_reply":"2022-02-06T20:15:36.956440Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Bonus: test data whales vs dolphins:","metadata":{}},{"cell_type":"code","source":"test_df = pd.read_csv('../input/happywhale-test-species/Happywhale_test_species.csv')\ntest_df['whale_dolphin'] = ['whale' if x in whale_species else 'dolphin' for x in test_df.species]\nprint(test_df.whale_dolphin.value_counts())\nfig = px.pie(test_df.whale_dolphin, \n             values=test_df.whale_dolphin.value_counts().values, \n             names=test_df.whale_dolphin.value_counts().index)\nfig.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-02-06T20:37:11.157014Z","iopub.execute_input":"2022-02-06T20:37:11.157861Z","iopub.status.idle":"2022-02-06T20:37:11.403411Z","shell.execute_reply.started":"2022-02-06T20:37:11.157803Z","shell.execute_reply":"2022-02-06T20:37:11.402532Z"},"trusted":true},"execution_count":null,"outputs":[]}]}