{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-10-30T02:09:26.915372Z","iopub.execute_input":"2022-10-30T02:09:26.915750Z","iopub.status.idle":"2022-10-30T02:09:55.723374Z","shell.execute_reply.started":"2022-10-30T02:09:26.915648Z","shell.execute_reply":"2022-10-30T02:09:55.720313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Describe the data\nimport pandas as pd\nbreed_labels = pd.read_csv(\"../input/dog-breed-identification/labels.csv\")\nbreed_labels.describe()","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:09:55.732775Z","iopub.execute_input":"2022-10-30T02:09:55.733037Z","iopub.status.idle":"2022-10-30T02:09:55.795720Z","shell.execute_reply.started":"2022-10-30T02:09:55.733001Z","shell.execute_reply":"2022-10-30T02:09:55.794890Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"breed_labels.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:10:29.403955Z","iopub.execute_input":"2022-10-30T02:10:29.404288Z","iopub.status.idle":"2022-10-30T02:10:29.414846Z","shell.execute_reply.started":"2022-10-30T02:10:29.404235Z","shell.execute_reply":"2022-10-30T02:10:29.413934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Number of Images in Each breeds\nbreed_labels[\"breed\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:10:33.992697Z","iopub.execute_input":"2022-10-30T02:10:33.993025Z","iopub.status.idle":"2022-10-30T02:10:34.002473Z","shell.execute_reply.started":"2022-10-30T02:10:33.992981Z","shell.execute_reply":"2022-10-30T02:10:34.001553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Lets Plot the data\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:10:37.911496Z","iopub.execute_input":"2022-10-30T02:10:37.911798Z","iopub.status.idle":"2022-10-30T02:10:37.916116Z","shell.execute_reply.started":"2022-10-30T02:10:37.911763Z","shell.execute_reply":"2022-10-30T02:10:37.914870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"breed_labels[\"breed\"].value_counts().plot.bar(figsize = (10, 15))","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:10:41.315877Z","iopub.execute_input":"2022-10-30T02:10:41.316202Z","iopub.status.idle":"2022-10-30T02:10:43.168210Z","shell.execute_reply.started":"2022-10-30T02:10:41.316164Z","shell.execute_reply":"2022-10-30T02:10:43.167185Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Changing the fisgsize may make it easier for us to understand the data better\nbreed_labels[\"breed\"].value_counts().plot.bar(figsize = (20, 10))","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:11:06.656023Z","iopub.execute_input":"2022-10-30T02:11:06.656362Z","iopub.status.idle":"2022-10-30T02:11:08.386107Z","shell.execute_reply.started":"2022-10-30T02:11:06.656324Z","shell.execute_reply":"2022-10-30T02:11:08.385314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"breed_labels[\"breed\"].value_counts().median()","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:11:17.597580Z","iopub.execute_input":"2022-10-30T02:11:17.597891Z","iopub.status.idle":"2022-10-30T02:11:17.607243Z","shell.execute_reply.started":"2022-10-30T02:11:17.597854Z","shell.execute_reply":"2022-10-30T02:11:17.606630Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# The median is 84 which also means that the data provided is well distributed. \n# Well distributed data rpoduces better results","metadata":{"execution":{"iopub.status.busy":"2022-05-30T14:32:31.149461Z","iopub.execute_input":"2022-05-30T14:32:31.149801Z","iopub.status.idle":"2022-05-30T14:32:31.155988Z","shell.execute_reply.started":"2022-05-30T14:32:31.149769Z","shell.execute_reply":"2022-05-30T14:32:31.155046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Check Images \nfrom IPython.display import Image\nImage(\"../input/dog-breed-identification/train/001513dfcb2ffafc82cccf4d8bbaba97.jpg\")","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:11:26.057007Z","iopub.execute_input":"2022-10-30T02:11:26.057364Z","iopub.status.idle":"2022-10-30T02:11:26.076365Z","shell.execute_reply.started":"2022-10-30T02:11:26.057327Z","shell.execute_reply":"2022-10-30T02:11:26.075525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Lets check one more\nImage(\"../input/dog-breed-identification/train/00a366d4b4a9bbb6c8a63126697b7656.jpg\")","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:11:33.350884Z","iopub.execute_input":"2022-10-30T02:11:33.351152Z","iopub.status.idle":"2022-10-30T02:11:33.365650Z","shell.execute_reply.started":"2022-10-30T02:11:33.351124Z","shell.execute_reply":"2022-10-30T02:11:33.365022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Getting the Images and their labels","metadata":{}},{"cell_type":"code","source":"breed_labels.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:11:40.487756Z","iopub.execute_input":"2022-10-30T02:11:40.488069Z","iopub.status.idle":"2022-10-30T02:11:40.499006Z","shell.execute_reply.started":"2022-10-30T02:11:40.488035Z","shell.execute_reply":"2022-10-30T02:11:40.498006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#A simple list comprehension method to store the id of all the picture in the\n#data to a file called names\nnames = [fname for fname in breed_labels[\"id\"]]\nnames[:10]","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:11:46.563466Z","iopub.execute_input":"2022-10-30T02:11:46.563760Z","iopub.status.idle":"2022-10-30T02:11:46.572936Z","shell.execute_reply.started":"2022-10-30T02:11:46.563728Z","shell.execute_reply":"2022-10-30T02:11:46.572066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Now, Lets add the file path to the ids\nnames = [\"../input/dog-breed-identification/train/\" + fname + \".jpg\" for fname in breed_labels[\"id\"] ]\nnames[:10]","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:11:48.734155Z","iopub.execute_input":"2022-10-30T02:11:48.735157Z","iopub.status.idle":"2022-10-30T02:11:48.746152Z","shell.execute_reply.started":"2022-10-30T02:11:48.735101Z","shell.execute_reply":"2022-10-30T02:11:48.745290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Image(names[1000])\n#Checking using the indices","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:12:01.679931Z","iopub.execute_input":"2022-10-30T02:12:01.680612Z","iopub.status.idle":"2022-10-30T02:12:01.695070Z","shell.execute_reply.started":"2022-10-30T02:12:01.680564Z","shell.execute_reply":"2022-10-30T02:12:01.694504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Check the breed\nbreed_labels[\"breed\"][1000]","metadata":{"execution":{"iopub.status.busy":"2022-10-30T02:12:06.765297Z","iopub.execute_input":"2022-10-30T02:12:06.765959Z","iopub.status.idle":"2022-10-30T02:12:06.771910Z","shell.execute_reply.started":"2022-10-30T02:12:06.765922Z","shell.execute_reply":"2022-10-30T02:12:06.771005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}