{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":7327,"databundleVersionId":861871,"sourceType":"competition"}],"dockerImageVersionId":30761,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Tensorflow","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\nimport seaborn as sns\nimport os\nimport tensorflow as tf\nfrom tensorflow import keras\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.metrics import confusion_matrix\nfrom sklearn.metrics import classification_report","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:21.464141Z","iopub.execute_input":"2024-09-07T07:27:21.464682Z","iopub.status.idle":"2024-09-07T07:27:39.218800Z","shell.execute_reply.started":"2024-09-07T07:27:21.464634Z","shell.execute_reply":"2024-09-07T07:27:39.217580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv = pd.read_csv('/kaggle/input/dog-breed-identification/labels.csv')\nlabels_csv","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:39.221342Z","iopub.execute_input":"2024-09-07T07:27:39.222084Z","iopub.status.idle":"2024-09-07T07:27:39.291411Z","shell.execute_reply.started":"2024-09-07T07:27:39.222038Z","shell.execute_reply":"2024-09-07T07:27:39.290335Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv.describe()","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:39.292631Z","iopub.execute_input":"2024-09-07T07:27:39.292986Z","iopub.status.idle":"2024-09-07T07:27:39.326285Z","shell.execute_reply.started":"2024-09-07T07:27:39.292948Z","shell.execute_reply":"2024-09-07T07:27:39.324857Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv.dtypes","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:39.329301Z","iopub.execute_input":"2024-09-07T07:27:39.330341Z","iopub.status.idle":"2024-09-07T07:27:39.338022Z","shell.execute_reply.started":"2024-09-07T07:27:39.330284Z","shell.execute_reply":"2024-09-07T07:27:39.336986Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv['breed'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:39.339195Z","iopub.execute_input":"2024-09-07T07:27:39.339595Z","iopub.status.idle":"2024-09-07T07:27:39.355759Z","shell.execute_reply.started":"2024-09-07T07:27:39.339555Z","shell.execute_reply":"2024-09-07T07:27:39.354472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv['breed'].value_counts().plot.bar(figsize=(20, 10))","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:39.357176Z","iopub.execute_input":"2024-09-07T07:27:39.357642Z","iopub.status.idle":"2024-09-07T07:27:41.018489Z","shell.execute_reply.started":"2024-09-07T07:27:39.357602Z","shell.execute_reply":"2024-09-07T07:27:41.017155Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv['breed'].value_counts().median()","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:41.020058Z","iopub.execute_input":"2024-09-07T07:27:41.020533Z","iopub.status.idle":"2024-09-07T07:27:41.034203Z","shell.execute_reply.started":"2024-09-07T07:27:41.020481Z","shell.execute_reply":"2024-09-07T07:27:41.032934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from IPython.display import display, Image\nImage('/kaggle/input/dog-breed-identification/train/001513dfcb2ffafc82cccf4d8bbaba97.jpg')","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:41.035610Z","iopub.execute_input":"2024-09-07T07:27:41.036018Z","iopub.status.idle":"2024-09-07T07:27:41.072223Z","shell.execute_reply.started":"2024-09-07T07:27:41.035959Z","shell.execute_reply":"2024-09-07T07:27:41.071049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fileNames = [\"/kaggle/input/dog-breed-identification/train\"+fname for fname in labels_csv['id']]\nfileNames[:10]","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:41.073590Z","iopub.execute_input":"2024-09-07T07:27:41.073947Z","iopub.status.idle":"2024-09-07T07:27:41.087677Z","shell.execute_reply.started":"2024-09-07T07:27:41.073909Z","shell.execute_reply":"2024-09-07T07:27:41.086489Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if len(os.listdir('/kaggle/input/dog-breed-identification/train')) == len(fileNames):\n    print('Number of file names match number of actual files!')\nelse:\n    print('Number of file names do not match number of actual files.')","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:41.092923Z","iopub.execute_input":"2024-09-07T07:27:41.093904Z","iopub.status.idle":"2024-09-07T07:27:42.075018Z","shell.execute_reply.started":"2024-09-07T07:27:41.093858Z","shell.execute_reply":"2024-09-07T07:27:42.073534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv['id'][9000]","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.077023Z","iopub.execute_input":"2024-09-07T07:27:42.077484Z","iopub.status.idle":"2024-09-07T07:27:42.085554Z","shell.execute_reply.started":"2024-09-07T07:27:42.077440Z","shell.execute_reply":"2024-09-07T07:27:42.084116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_csv['breed'][9000]","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.087159Z","iopub.execute_input":"2024-09-07T07:27:42.087577Z","iopub.status.idle":"2024-09-07T07:27:42.107158Z","shell.execute_reply.started":"2024-09-07T07:27:42.087536Z","shell.execute_reply":"2024-09-07T07:27:42.105644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels=labels_csv['breed']\nlabels=np.array(labels)\nlabels","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.108858Z","iopub.execute_input":"2024-09-07T07:27:42.109403Z","iopub.status.idle":"2024-09-07T07:27:42.124438Z","shell.execute_reply.started":"2024-09-07T07:27:42.109355Z","shell.execute_reply":"2024-09-07T07:27:42.123188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(labels)","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.125904Z","iopub.execute_input":"2024-09-07T07:27:42.126361Z","iopub.status.idle":"2024-09-07T07:27:42.136135Z","shell.execute_reply.started":"2024-09-07T07:27:42.126318Z","shell.execute_reply":"2024-09-07T07:27:42.134896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if len(labels) == len(fileNames):\n    print('Number of labels match number of file names!')\nelse:\n    print('Number of labels do not match number of file names.')","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.137629Z","iopub.execute_input":"2024-09-07T07:27:42.138056Z","iopub.status.idle":"2024-09-07T07:27:42.151725Z","shell.execute_reply.started":"2024-09-07T07:27:42.138012Z","shell.execute_reply":"2024-09-07T07:27:42.150295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"unique_breeds = np.unique(labels)\nunique_breeds","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.153502Z","iopub.execute_input":"2024-09-07T07:27:42.153970Z","iopub.status.idle":"2024-09-07T07:27:42.182904Z","shell.execute_reply.started":"2024-09-07T07:27:42.153923Z","shell.execute_reply":"2024-09-07T07:27:42.179857Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(unique_breeds)","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.185256Z","iopub.execute_input":"2024-09-07T07:27:42.185829Z","iopub.status.idle":"2024-09-07T07:27:42.196485Z","shell.execute_reply.started":"2024-09-07T07:27:42.185780Z","shell.execute_reply":"2024-09-07T07:27:42.195035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(labels[0])\nlabels[0] == unique_breeds","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.198452Z","iopub.execute_input":"2024-09-07T07:27:42.199437Z","iopub.status.idle":"2024-09-07T07:27:42.213892Z","shell.execute_reply.started":"2024-09-07T07:27:42.199386Z","shell.execute_reply":"2024-09-07T07:27:42.212471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"boolean_labels = [label == unique_breeds for label in labels]\nboolean_labels[:2]","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.215646Z","iopub.execute_input":"2024-09-07T07:27:42.216227Z","iopub.status.idle":"2024-09-07T07:27:42.340534Z","shell.execute_reply.started":"2024-09-07T07:27:42.216176Z","shell.execute_reply":"2024-09-07T07:27:42.339198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(boolean_labels)","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.342462Z","iopub.execute_input":"2024-09-07T07:27:42.343419Z","iopub.status.idle":"2024-09-07T07:27:42.351842Z","shell.execute_reply.started":"2024-09-07T07:27:42.343354Z","shell.execute_reply":"2024-09-07T07:27:42.350425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(labels[0])\nprint(np.where(unique_breeds == labels[0]))\nprint(boolean_labels[0].argmax())\nprint(boolean_labels[0].astype(int))","metadata":{"execution":{"iopub.status.busy":"2024-09-07T07:27:42.353471Z","iopub.execute_input":"2024-09-07T07:27:42.353975Z","iopub.status.idle":"2024-09-07T07:27:42.367731Z","shell.execute_reply.started":"2024-09-07T07:27:42.353929Z","shell.execute_reply":"2024-09-07T07:27:42.366241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 228","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}