{"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":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-09-23T05:07:42.623264Z","iopub.execute_input":"2023-09-23T05:07:42.623680Z","iopub.status.idle":"2023-09-23T05:07:42.630098Z","shell.execute_reply.started":"2023-09-23T05:07:42.623645Z","shell.execute_reply":"2023-09-23T05:07:42.628696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv(\"/kaggle/input/snakeclef2022/SnakeCLEF2022-TrainMetadata.csv\")\ntest_df = pd.read_csv(\"/kaggle/input/snakeclef2022/SnakeCLEF2022-TestMetadata.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:42.632199Z","iopub.execute_input":"2023-09-23T05:07:42.632636Z","iopub.status.idle":"2023-09-23T05:07:43.128665Z","shell.execute_reply.started":"2023-09-23T05:07:42.632596Z","shell.execute_reply":"2023-09-23T05:07:43.127607Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.130475Z","iopub.execute_input":"2023-09-23T05:07:43.130856Z","iopub.status.idle":"2023-09-23T05:07:43.146157Z","shell.execute_reply.started":"2023-09-23T05:07:43.130827Z","shell.execute_reply":"2023-09-23T05:07:43.145036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.shape","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.147932Z","iopub.execute_input":"2023-09-23T05:07:43.148596Z","iopub.status.idle":"2023-09-23T05:07:43.158517Z","shell.execute_reply.started":"2023-09-23T05:07:43.148533Z","shell.execute_reply":"2023-09-23T05:07:43.157528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df[\"country\"].nunique()","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.161780Z","iopub.execute_input":"2023-09-23T05:07:43.162136Z","iopub.status.idle":"2023-09-23T05:07:43.195841Z","shell.execute_reply.started":"2023-09-23T05:07:43.162101Z","shell.execute_reply":"2023-09-23T05:07:43.194609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df[\"code\"].nunique()","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.197625Z","iopub.execute_input":"2023-09-23T05:07:43.197977Z","iopub.status.idle":"2023-09-23T05:07:43.226891Z","shell.execute_reply.started":"2023-09-23T05:07:43.197943Z","shell.execute_reply":"2023-09-23T05:07:43.225854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"THERE ARE 207 DIFFERENT COUNTRIES.\nWE ARE FOCUSING ON THE INIDAN SUB CONTINENT. SO WE WILL MODIFY THE DATA ACCORDINGLY.","metadata":{}},{"cell_type":"code","source":"np.set_printoptions(threshold=np.inf)\narr = train_df[\"code\"].unique()\nprint(arr)","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.228280Z","iopub.execute_input":"2023-09-23T05:07:43.228743Z","iopub.status.idle":"2023-09-23T05:07:43.258457Z","shell.execute_reply.started":"2023-09-23T05:07:43.228706Z","shell.execute_reply":"2023-09-23T05:07:43.257267Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"item = \"MV\"\nif item in arr:\n    print(\"YES\")","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.260291Z","iopub.execute_input":"2023-09-23T05:07:43.260762Z","iopub.status.idle":"2023-09-23T05:07:43.266973Z","shell.execute_reply.started":"2023-09-23T05:07:43.260725Z","shell.execute_reply":"2023-09-23T05:07:43.265517Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = train_df[(train_df[\"code\"]==\"IN\") | (train_df[\"code\"]==\"BD\") | (train_df[\"code\"]==\"BT\") |\n                      (train_df[\"code\"]==\"MV\") | (train_df[\"code\"]==\"NP\") | (train_df[\"code\"]==\"PK\") |\n                      (train_df[\"code\"]==\"LK\")]","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.268654Z","iopub.execute_input":"2023-09-23T05:07:43.269378Z","iopub.status.idle":"2023-09-23T05:07:43.563941Z","shell.execute_reply.started":"2023-09-23T05:07:43.269338Z","shell.execute_reply":"2023-09-23T05:07:43.562939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.head()","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.565679Z","iopub.execute_input":"2023-09-23T05:07:43.566090Z","iopub.status.idle":"2023-09-23T05:07:43.581769Z","shell.execute_reply.started":"2023-09-23T05:07:43.566049Z","shell.execute_reply":"2023-09-23T05:07:43.580815Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.shape","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.586000Z","iopub.execute_input":"2023-09-23T05:07:43.586308Z","iopub.status.idle":"2023-09-23T05:07:43.595114Z","shell.execute_reply.started":"2023-09-23T05:07:43.586280Z","shell.execute_reply":"2023-09-23T05:07:43.593991Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data = test_df[(test_df[\"code\"]==\"IN\") | (test_df[\"code\"]==\"BD\") | (test_df[\"code\"]==\"BT\") |\n                      (test_df[\"code\"]==\"MV\") | (test_df[\"code\"]==\"NP\") | (test_df[\"code\"]==\"PK\") |\n                      (test_df[\"code\"]==\"LK\")]","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.596864Z","iopub.execute_input":"2023-09-23T05:07:43.597341Z","iopub.status.idle":"2023-09-23T05:07:43.660723Z","shell.execute_reply.started":"2023-09-23T05:07:43.597303Z","shell.execute_reply":"2023-09-23T05:07:43.659769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.shape","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.663266Z","iopub.execute_input":"2023-09-23T05:07:43.664134Z","iopub.status.idle":"2023-09-23T05:07:43.671421Z","shell.execute_reply.started":"2023-09-23T05:07:43.664095Z","shell.execute_reply":"2023-09-23T05:07:43.670422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"WE HAVE 9413 DATA POINTS FOR TRAINING AND 1729 IMAGES FOR TESTING PURPOSE.","metadata":{}},{"cell_type":"markdown","source":"# EDA","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(18,6))\nsns.countplot(x=\"country\",data=train_data)\nplt.xticks(rotation=90)\nplt.title(\"NO OF SNAKES IN DIFFERENT REGIONS\",size=20)\nplt.xlabel(\"REGIONS\",size=17)\nplt.ylabel(\"NO OF IMAGES\",size=17)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:43.672904Z","iopub.execute_input":"2023-09-23T05:07:43.673469Z","iopub.status.idle":"2023-09-23T05:07:44.934718Z","shell.execute_reply.started":"2023-09-23T05:07:43.673343Z","shell.execute_reply":"2023-09-23T05:07:44.933618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"MOST OF THE SNAKES ARE FROM KARNATAK,MAHARASHTRA & TAMILNADU REGIONS.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(8,12))\ncode_counts = train_data[\"code\"].value_counts()\nexp = [0,0.1,0.2,0.2,0.2,0.2,0.2]\ncode_counts.plot(kind=\"pie\",autopct='%1.1f%%',explode=exp,fontsize=14)\nplt.title(\"NO OF SNAKES IN DIFFERENT COUNTRIES\",size=16)\nplt.legend(fontsize=10)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:44.936091Z","iopub.execute_input":"2023-09-23T05:07:44.937021Z","iopub.status.idle":"2023-09-23T05:07:45.294326Z","shell.execute_reply.started":"2023-09-23T05:07:44.936981Z","shell.execute_reply":"2023-09-23T05:07:45.293346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"MAXIMUM SNAKES' IMAGES WERE TAKEN FROM INDIA.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(8,12))\ncode_counts = train_data[\"endemic\"].value_counts()\nexp = [0,0.2]\ncolors=[\"green\",\"red\"]\ncode_counts.plot(kind=\"pie\",autopct='%1.1f%%',explode=exp,fontsize=14,colors=colors)\nplt.title(\"SNAKES ARE ENDEMIC OR NOT\",size=16)\nplt.legend(fontsize=12)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:45.296699Z","iopub.execute_input":"2023-09-23T05:07:45.297323Z","iopub.status.idle":"2023-09-23T05:07:45.522089Z","shell.execute_reply.started":"2023-09-23T05:07:45.297283Z","shell.execute_reply":"2023-09-23T05:07:45.520873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"MOST OF THE SNAKE SPECIES ARE NOT ENDEMIC.","metadata":{}},{"cell_type":"code","source":"top_type_snakes = train_data.groupby(\"binomial_name\").binomial_name.count().nlargest(n=10)","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:45.523846Z","iopub.execute_input":"2023-09-23T05:07:45.524508Z","iopub.status.idle":"2023-09-23T05:07:45.536520Z","shell.execute_reply.started":"2023-09-23T05:07:45.524466Z","shell.execute_reply":"2023-09-23T05:07:45.534982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,8))\ntop_type_snakes.plot(kind=\"bar\",fontsize = 15,color=\"blue\")\nplt.title(\"TOP 1O SNAKES BY THEIR CATEGORY\",size=20)\nplt.xticks(rotation=45)\nplt.xlabel(\"TYPES OF SNAKES\",size=17)\nplt.ylabel(\"NO OF IMAGES\",size=17)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-23T05:07:45.538615Z","iopub.execute_input":"2023-09-23T05:07:45.539366Z","iopub.status.idle":"2023-09-23T05:07:45.826480Z","shell.execute_reply.started":"2023-09-23T05:07:45.539326Z","shell.execute_reply":"2023-09-23T05:07:45.825479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"PTYAS MUCOSA SPECIES HAVE THE MOST NO OF IMAGES IN THE DATASET.","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}