{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.6.6","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":11307,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, Flatten\nfrom tensorflow.keras.datasets import mnist\nfrom tensorflow.keras.utils import to_categorical\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split","metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_kg_hide-output":true,"_kg_hide-input":true,"execution":{"iopub.status.busy":"2024-11-25T09:38:55.4762Z","iopub.execute_input":"2024-11-25T09:38:55.476456Z","iopub.status.idle":"2024-11-25T09:38:56.210392Z","shell.execute_reply.started":"2024-11-25T09:38:55.476406Z","shell.execute_reply":"2024-11-25T09:38:56.209635Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Veriyi Yükle\ntrain = pd.read_csv(\"../input/train.csv\")\ntest = pd.read_csv(\"../input/test.csv\")","metadata":{"_uuid":"d71b3fa2b10620dc8870352fc18d4548f824a88a","execution":{"iopub.status.busy":"2024-11-25T09:11:17.243325Z","iopub.execute_input":"2024-11-25T09:11:17.243572Z","iopub.status.idle":"2024-11-25T09:11:23.124703Z","shell.execute_reply.started":"2024-11-25T09:11:17.243533Z","shell.execute_reply":"2024-11-25T09:11:23.124091Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# PREPARE DATA FOR NEURAL NETWORK\nY_train = train[\"label\"]\nX_train = train.drop(labels = [\"label\"],axis = 1)\nX_train = X_train / 255.0\nX_test = test / 255.0\n\nY_train = to_categorical(Y_train, num_classes = 10)\n\nX_train, X_test, Y_train, Y_test = train_test_split(X_train, Y_train, test_size=0.25, random_state=42)","metadata":{"_kg_hide-input":true,"_uuid":"b3c56055d1ba56d28d982f9647c33439c46753ff","execution":{"iopub.status.busy":"2024-11-25T09:38:59.19195Z","iopub.execute_input":"2024-11-25T09:38:59.19219Z","iopub.status.idle":"2024-11-25T09:39:00.393283Z","shell.execute_reply.started":"2024-11-25T09:38:59.192153Z","shell.execute_reply":"2024-11-25T09:39:00.39274Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = Sequential([\n    Dense(128, activation='relu', input_shape=(784,)),\n    Dense(64, activation='relu'),\n    Dense(10, activation='softmax')\n])\n\n\n# Modeli derleyelim\nmodel.compile(optimizer='adam',\n              loss='categorical_crossentropy',\n              metrics=['accuracy'])\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-25T09:39:03.400625Z","iopub.execute_input":"2024-11-25T09:39:03.400917Z","iopub.status.idle":"2024-11-25T09:39:03.528891Z","shell.execute_reply.started":"2024-11-25T09:39:03.400874Z","shell.execute_reply":"2024-11-25T09:39:03.528278Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Modeli eğitelim\nmodel.fit(X_train, Y_train, epochs=10, batch_size=32, verbose=1)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-25T09:39:06.242486Z","iopub.execute_input":"2024-11-25T09:39:06.242935Z","iopub.status.idle":"2024-11-25T09:40:06.451021Z","shell.execute_reply.started":"2024-11-25T09:39:06.242854Z","shell.execute_reply":"2024-11-25T09:40:06.450322Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Test verisi ile modeli değerlendirelim\ntest_loss, test_acc = model.evaluate(X_test, Y_test, verbose=2)\nprint('\\nTest doğruluğu:', test_acc)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-25T09:40:15.49474Z","iopub.execute_input":"2024-11-25T09:40:15.495022Z","iopub.status.idle":"2024-11-25T09:40:16.325334Z","shell.execute_reply.started":"2024-11-25T09:40:15.494971Z","shell.execute_reply":"2024-11-25T09:40:16.324564Z"}},"outputs":[],"execution_count":null}]}