{"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-02-25T11:17:57.276683Z","iopub.execute_input":"2022-02-25T11:17:57.277784Z","iopub.status.idle":"2022-02-25T11:17:57.291797Z","shell.execute_reply.started":"2022-02-25T11:17:57.277719Z","shell.execute_reply":"2022-02-25T11:17:57.290501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import 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        ","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:17:57.293726Z","iopub.execute_input":"2022-02-25T11:17:57.294012Z","iopub.status.idle":"2022-02-25T11:17:57.304176Z","shell.execute_reply.started":"2022-02-25T11:17:57.293978Z","shell.execute_reply":"2022-02-25T11:17:57.30314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataTrain=pd.read_csv('/kaggle/input/digit-recognizer/train.csv')\ndataTest=pd.read_csv('/kaggle/input/digit-recognizer/test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:17:57.311294Z","iopub.execute_input":"2022-02-25T11:17:57.31166Z","iopub.status.idle":"2022-02-25T11:18:03.43105Z","shell.execute_reply.started":"2022-02-25T11:17:57.311622Z","shell.execute_reply":"2022-02-25T11:18:03.43009Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataTrain","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:18:03.43346Z","iopub.execute_input":"2022-02-25T11:18:03.43384Z","iopub.status.idle":"2022-02-25T11:18:03.477726Z","shell.execute_reply.started":"2022-02-25T11:18:03.433784Z","shell.execute_reply":"2022-02-25T11:18:03.476636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(dataTrain.shape)\ndataTest.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:18:03.479116Z","iopub.execute_input":"2022-02-25T11:18:03.479423Z","iopub.status.idle":"2022-02-25T11:18:03.487488Z","shell.execute_reply.started":"2022-02-25T11:18:03.47938Z","shell.execute_reply":"2022-02-25T11:18:03.486122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"xTrain=dataTrain.iloc[:,1:]\nyTrain=dataTrain.iloc[:,0]\nxTest=dataTest.copy()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:18:03.490356Z","iopub.execute_input":"2022-02-25T11:18:03.490725Z","iopub.status.idle":"2022-02-25T11:18:03.592759Z","shell.execute_reply.started":"2022-02-25T11:18:03.490684Z","shell.execute_reply":"2022-02-25T11:18:03.591785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"xTrain","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:18:03.594102Z","iopub.execute_input":"2022-02-25T11:18:03.594338Z","iopub.status.idle":"2022-02-25T11:18:03.622526Z","shell.execute_reply.started":"2022-02-25T11:18:03.594307Z","shell.execute_reply":"2022-02-25T11:18:03.621534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"yTrain","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:18:03.62384Z","iopub.execute_input":"2022-02-25T11:18:03.624175Z","iopub.status.idle":"2022-02-25T11:18:03.632454Z","shell.execute_reply.started":"2022-02-25T11:18:03.624143Z","shell.execute_reply":"2022-02-25T11:18:03.631718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(xTrain.shape)\nprint(yTrain.shape)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:18:03.633627Z","iopub.execute_input":"2022-02-25T11:18:03.633869Z","iopub.status.idle":"2022-02-25T11:18:03.648402Z","shell.execute_reply.started":"2022-02-25T11:18:03.633841Z","shell.execute_reply":"2022-02-25T11:18:03.647397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import random\nfrom random import sample\n\ntemp=sample(range(0,42000),10)\n\ntemp","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:18:03.650196Z","iopub.execute_input":"2022-02-25T11:18:03.650526Z","iopub.status.idle":"2022-02-25T11:18:03.665755Z","shell.execute_reply.started":"2022-02-25T11:18:03.650482Z","shell.execute_reply":"2022-02-25T11:18:03.664717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sb\n\nfor i in temp:\n    plt.subplot(1,2,1)\n    plt.imshow(xTrain.iloc[i].values.reshape((28,28)), cmap=plt.cm.binary)\n    plt.title('label(y-train) : {}'.format(yTrain.iloc[i]))\n    plt.subplot(1,2,2)\n    sb.histplot(xTrain.iloc[i].values, kde=True)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:35:09.111828Z","iopub.execute_input":"2022-02-25T11:35:09.112429Z","iopub.status.idle":"2022-02-25T11:35:12.301424Z","shell.execute_reply.started":"2022-02-25T11:35:09.112371Z","shell.execute_reply":"2022-02-25T11:35:12.300423Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import MinMaxScaler\nfrom keras.utils.np_utils import to_categorical\n\nscaler=MinMaxScaler(feature_range=(0,1))\n\nxTrainScaled=scaler.fit_transform(xTrain)\nxTestScaled=scaler.transform(xTest)\nyTrainScaled=to_categorical(yTrain)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:39:09.162171Z","iopub.execute_input":"2022-02-25T11:39:09.162461Z","iopub.status.idle":"2022-02-25T11:39:16.451417Z","shell.execute_reply.started":"2022-02-25T11:39:09.162431Z","shell.execute_reply":"2022-02-25T11:39:16.450216Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(X_train_scaled, y_train, epochs=25, batch_size=512, validation_split=0.20)","metadata":{"execution":{"iopub.status.busy":"2022-02-25T11:41:49.588584Z","iopub.execute_input":"2022-02-25T11:41:49.588995Z","iopub.status.idle":"2022-02-25T11:41:49.826991Z","shell.execute_reply.started":"2022-02-25T11:41:49.588876Z","shell.execute_reply":"2022-02-25T11:41:49.825596Z"},"trusted":true},"execution_count":null,"outputs":[]}]}