{"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-10-10T10:19:00.707143Z","iopub.execute_input":"2023-10-10T10:19:00.707648Z","iopub.status.idle":"2023-10-10T10:19:02.111708Z","shell.execute_reply.started":"2023-10-10T10:19:00.707551Z","shell.execute_reply":"2023-10-10T10:19:02.110245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv(\"/kaggle/input/snakeclef2022/SnakeCLEF2022-TrainMetadata.csv\")\ntrain_df['file_path']=\"/kaggle/input/snakeclef2022/SnakeCLEF2022-medium_size/SnakeCLEF2022-medium_size/\"+train_df['file_path']","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:19:02.113684Z","iopub.execute_input":"2023-10-10T10:19:02.114091Z","iopub.status.idle":"2023-10-10T10:19:03.239352Z","shell.execute_reply.started":"2023-10-10T10:19:02.114054Z","shell.execute_reply":"2023-10-10T10:19:03.237939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:20:26.598039Z","iopub.execute_input":"2023-10-10T10:20:26.598398Z","iopub.status.idle":"2023-10-10T10:20:26.618652Z","shell.execute_reply.started":"2023-10-10T10:20:26.598369Z","shell.execute_reply":"2023-10-10T10:20:26.617278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.shape","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:20:27.156829Z","iopub.execute_input":"2023-10-10T10:20:27.157241Z","iopub.status.idle":"2023-10-10T10:20:27.165602Z","shell.execute_reply.started":"2023-10-10T10:20:27.157204Z","shell.execute_reply":"2023-10-10T10:20:27.164300Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### There are more than 2,70,000 images of different Snake species in the whole dataset.","metadata":{}},{"cell_type":"code","source":"train_df[\"code\"].nunique()","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:20:29.142693Z","iopub.execute_input":"2023-10-10T10:20:29.143751Z","iopub.status.idle":"2023-10-10T10:20:29.175017Z","shell.execute_reply.started":"2023-10-10T10:20:29.143669Z","shell.execute_reply":"2023-10-10T10:20:29.173163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### THERE ARE 207 DIFFERENT COUNTRIES. WE ARE FOCUSING ONLY 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-10-10T10:21:06.948102Z","iopub.execute_input":"2023-10-10T10:21:06.948559Z","iopub.status.idle":"2023-10-10T10:21:06.972206Z","shell.execute_reply.started":"2023-10-10T10:21:06.948520Z","shell.execute_reply":"2023-10-10T10:21:06.970806Z"},"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-10-10T10:21:07.636784Z","iopub.execute_input":"2023-10-10T10:21:07.637811Z","iopub.status.idle":"2023-10-10T10:21:07.793552Z","shell.execute_reply.started":"2023-10-10T10:21:07.637756Z","shell.execute_reply":"2023-10-10T10:21:07.792540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data[\"binomial_name\"].nunique()","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:21:10.266785Z","iopub.execute_input":"2023-10-10T10:21:10.267204Z","iopub.status.idle":"2023-10-10T10:21:10.277072Z","shell.execute_reply.started":"2023-10-10T10:21:10.267167Z","shell.execute_reply":"2023-10-10T10:21:10.275822Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top_type_snakes = train_data.groupby(\"binomial_name\").binomial_name.count().nlargest(n=10)\nplt.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-10-10T10:23:04.159434Z","iopub.execute_input":"2023-10-10T10:23:04.159877Z","iopub.status.idle":"2023-10-10T10:23:04.512604Z","shell.execute_reply.started":"2023-10-10T10:23:04.159837Z","shell.execute_reply":"2023-10-10T10:23:04.511706Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### There are 151 diffrent species of snaked in Indian subcontinet. But we are concerned about the four deadly venomous Snakes that includes NAJA NAJA, BUNGARUS CAERULES, DABOIA RUSSELII, ECHIS CARINATUS.","metadata":{}},{"cell_type":"code","source":"snake_df = train_data[(train_data[\"binomial_name\"]==\"Naja naja\") | (train_data[\"binomial_name\"]==\"Bungarus caeruleus\") |\n                      (train_data[\"binomial_name\"]==\"Daboia russelii\") | (train_data[\"binomial_name\"]==\"Echis carinatus\") ]","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:23:34.942325Z","iopub.execute_input":"2023-10-10T10:23:34.942788Z","iopub.status.idle":"2023-10-10T10:23:34.961121Z","shell.execute_reply.started":"2023-10-10T10:23:34.942715Z","shell.execute_reply":"2023-10-10T10:23:34.959649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"snake_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:23:36.002076Z","iopub.execute_input":"2023-10-10T10:23:36.003118Z","iopub.status.idle":"2023-10-10T10:23:36.017412Z","shell.execute_reply.started":"2023-10-10T10:23:36.003078Z","shell.execute_reply":"2023-10-10T10:23:36.016110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"snake_df.shape","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:23:38.822125Z","iopub.execute_input":"2023-10-10T10:23:38.822662Z","iopub.status.idle":"2023-10-10T10:23:38.831178Z","shell.execute_reply.started":"2023-10-10T10:23:38.822617Z","shell.execute_reply":"2023-10-10T10:23:38.829687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Now there are total 1305 images of snakes belonging to four species.","metadata":{}},{"cell_type":"code","source":"snake_df.info","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:23:41.121690Z","iopub.execute_input":"2023-10-10T10:23:41.122668Z","iopub.status.idle":"2023-10-10T10:23:41.136755Z","shell.execute_reply.started":"2023-10-10T10:23:41.122630Z","shell.execute_reply":"2023-10-10T10:23:41.135379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### SAMPLE IMAGE","metadata":{}},{"cell_type":"code","source":"from PIL import Image\na=130\nimage = Image.open(snake_df.iloc[a][\"file_path\"])\nimage = image.resize((128,128))\nplt.figure(figsize=(4,4))\nplt.axis(False)\nplt.imshow(image)\nprint(snake_df.iloc[a][\"binomial_name\"])\nplt.savefig('Bungarus_caeruleus.png')","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:23:43.962334Z","iopub.execute_input":"2023-10-10T10:23:43.962711Z","iopub.status.idle":"2023-10-10T10:23:44.211166Z","shell.execute_reply.started":"2023-10-10T10:23:43.962681Z","shell.execute_reply":"2023-10-10T10:23:44.209958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# EDA","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(18,6))\nsns.countplot(x=\"country\",data=snake_df)\nplt.xticks(rotation=90)\nplt.title(\"NUMBER 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-10-10T10:23:52.601815Z","iopub.execute_input":"2023-10-10T10:23:52.602239Z","iopub.status.idle":"2023-10-10T10:23:53.067958Z","shell.execute_reply.started":"2023-10-10T10:23:52.602194Z","shell.execute_reply":"2023-10-10T10:23:53.066764Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### MOST OF THE SNAKES ARE FROM KARNATAK & MAHARASHTRA REGIONS.","metadata":{}},{"cell_type":"code","source":"palette_color = sns.color_palette(\"hls\", 8) \nsns.set_style(\"darkgrid\")\nplt.figure(figsize=(10,14))\ncode_counts = snake_df[\"binomial_name\"].value_counts()\ncode_counts.plot(kind=\"pie\",autopct='%1.1f%%',fontsize=14,colors = palette_color,label=\"\",shadow={'ox': -0.04, 'edgecolor': 'none', 'shade': 0.9}, startangle=90)\nplt.title(\"NUMBER OF SNAKES IN DIFFERENT SPECIES\",size=18)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-10-10T11:19:51.445843Z","iopub.execute_input":"2023-10-10T11:19:51.446225Z","iopub.status.idle":"2023-10-10T11:19:51.663647Z","shell.execute_reply.started":"2023-10-10T11:19:51.446193Z","shell.execute_reply":"2023-10-10T11:19:51.662194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(8,12))\ncode_counts = snake_df[\"code\"].value_counts()\nexplodes = [0,0.1,0.3,0.3,0.3]\ncode_counts.plot(kind=\"pie\",autopct='%1.1f%%',fontsize=14,explode=explodes,label=\"\")\nplt.title(\"NUMBER OF SNAKES IN DIFFERENT COUNTRIES\",size=16)\nplt.legend(fontsize=10)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-10-10T10:54:51.675109Z","iopub.execute_input":"2023-10-10T10:54:51.675528Z","iopub.status.idle":"2023-10-10T10:54:51.979193Z","shell.execute_reply.started":"2023-10-10T10:54:51.675487Z","shell.execute_reply":"2023-10-10T10:54:51.977938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### MAXIMUM IMAGES OF SNAKES WERE TAKEN FROM INDIA.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(12,8))\nsns.set_style(\"darkgrid\")\nsns.countplot(x=\"binomial_name\",data=snake_df,palette=\"Set2\")\nplt.xticks(size=14)\nplt.yticks(size=13)\nplt.title(\"Number of Snakes of Different Species\",size=20)\nplt.xlabel(\"Types of Snake Species\",size=17,labelpad=20.0)\nplt.ylabel(\"Number of Snake Images\",size=17,labelpad=20.0)\nplt.savefig(\"Number_of_Snakes.png\")\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-10-10T11:21:41.755526Z","iopub.execute_input":"2023-10-10T11:21:41.755954Z","iopub.status.idle":"2023-10-10T11:21:42.024108Z","shell.execute_reply.started":"2023-10-10T11:21:41.755912Z","shell.execute_reply":"2023-10-10T11:21:42.022755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### NAJA NAJA SPECIES HAS THE MOST NO OF IMAGES IN OUR DATA.","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}