{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":3004,"databundleVersionId":861823,"sourceType":"competition"}],"dockerImageVersionId":30699,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"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":"2024-05-25T12:42:40.323283Z","iopub.execute_input":"2024-05-25T12:42:40.323610Z","iopub.status.idle":"2024-05-25T12:42:40.678931Z","shell.execute_reply.started":"2024-05-25T12:42:40.323585Z","shell.execute_reply":"2024-05-25T12:42:40.677949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/digit-recognizer/train.csv')\ntrain_df2 = train_df.drop(columns = 'label')\ntrain_arr = np.array(train_df2)\nX = train_arr.T\ny_data = np.array(train_df)\ny_data=y_data.T\nY = y_data[0]\nX","metadata":{"execution":{"iopub.status.busy":"2024-05-25T12:42:40.732752Z","iopub.execute_input":"2024-05-25T12:42:40.733180Z","iopub.status.idle":"2024-05-25T12:42:44.520824Z","shell.execute_reply.started":"2024-05-25T12:42:40.733152Z","shell.execute_reply":"2024-05-25T12:42:44.519882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras import Sequential\nfrom tensorflow.keras.layers import Dense\nfrom tensorflow.keras.losses import SparseCategoricalCrossentropy","metadata":{"execution":{"iopub.status.busy":"2024-05-25T12:42:44.522448Z","iopub.execute_input":"2024-05-25T12:42:44.522735Z","iopub.status.idle":"2024-05-25T12:42:55.052135Z","shell.execute_reply.started":"2024-05-25T12:42:44.522705Z","shell.execute_reply":"2024-05-25T12:42:55.051136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = Sequential([Dense(128, activation='relu', input_shape=(784,)), Dense(units = 10, activation = 'sigmoid'), Dense(units = 10, activation = 'softmax')])","metadata":{"execution":{"iopub.status.busy":"2024-05-25T12:42:55.053469Z","iopub.execute_input":"2024-05-25T12:42:55.054212Z","iopub.status.idle":"2024-05-25T12:42:55.686217Z","shell.execute_reply.started":"2024-05-25T12:42:55.054163Z","shell.execute_reply":"2024-05-25T12:42:55.685293Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(loss = 'sparse_categorical_crossentropy')\nmodel.fit(X.T, Y, epochs = 100)","metadata":{"execution":{"iopub.status.busy":"2024-05-25T12:42:55.688308Z","iopub.execute_input":"2024-05-25T12:42:55.688606Z","iopub.status.idle":"2024-05-25T12:46:07.364874Z","shell.execute_reply.started":"2024-05-25T12:42:55.688581Z","shell.execute_reply":"2024-05-25T12:46:07.363879Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.read_csv('/kaggle/input/digit-recognizer/test.csv')\nx = np.array(df)\nz=model.predict(x)\n","metadata":{"execution":{"iopub.status.busy":"2024-05-25T12:58:23.305386Z","iopub.execute_input":"2024-05-25T12:58:23.305753Z","iopub.status.idle":"2024-05-25T12:58:26.827977Z","shell.execute_reply.started":"2024-05-25T12:58:23.305718Z","shell.execute_reply":"2024-05-25T12:58:26.827047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"array=[]\nfor i in range(len(z)):\n    maximum = 0\n    index=0\n    for j in range(10):\n        if maximum<z[i][j]:\n            maximum = z[i][j]\n            index=j\n    array.append(index)\narray","metadata":{"execution":{"iopub.status.busy":"2024-05-25T13:09:11.638090Z","iopub.execute_input":"2024-05-25T13:09:11.638453Z","iopub.status.idle":"2024-05-25T13:09:11.968081Z","shell.execute_reply.started":"2024-05-25T13:09:11.638428Z","shell.execute_reply":"2024-05-25T13:09:11.967143Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}