{"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)\nfrom zipfile import ZipFile\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-05-26T18:23:56.951926Z","iopub.execute_input":"2022-05-26T18:23:56.952302Z","iopub.status.idle":"2022-05-26T18:23:56.983857Z","shell.execute_reply.started":"2022-05-26T18:23:56.952193Z","shell.execute_reply":"2022-05-26T18:23:56.983145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:23:56.985449Z","iopub.execute_input":"2022-05-26T18:23:56.985961Z","iopub.status.idle":"2022-05-26T18:23:57.903165Z","shell.execute_reply.started":"2022-05-26T18:23:56.985927Z","shell.execute_reply":"2022-05-26T18:23:57.9023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nimport random\nimport pickle\nfrom tqdm import tqdm\nimport matplotlib.pyplot as plt\n","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:23:57.906257Z","iopub.execute_input":"2022-05-26T18:23:57.906713Z","iopub.status.idle":"2022-05-26T18:23:58.223288Z","shell.execute_reply.started":"2022-05-26T18:23:57.906681Z","shell.execute_reply":"2022-05-26T18:23:58.222639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras.datasets import cifar10\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, Dropout, Activation, Flatten\nfrom tensorflow.keras.layers import Conv2D, MaxPooling2D","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:23:58.225895Z","iopub.execute_input":"2022-05-26T18:23:58.226157Z","iopub.status.idle":"2022-05-26T18:24:03.820887Z","shell.execute_reply.started":"2022-05-26T18:23:58.226121Z","shell.execute_reply":"2022-05-26T18:24:03.820055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nwith ZipFile('/kaggle/input/dogs-vs-cats-redux-kernels-edition/train.zip', 'r') as zip:\n    #zip.printdir()\n    zip.extractall()\n    print('done')\n","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:03.822318Z","iopub.execute_input":"2022-05-26T18:24:03.822587Z","iopub.status.idle":"2022-05-26T18:24:15.10882Z","shell.execute_reply.started":"2022-05-26T18:24:03.822538Z","shell.execute_reply":"2022-05-26T18:24:15.107952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with ZipFile('/kaggle/input/dogs-vs-cats-redux-kernels-edition/test.zip', 'r') as zip:\n    #zip.printdir()\n    zip.extractall()\n    print('done')\n","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:15.110147Z","iopub.execute_input":"2022-05-26T18:24:15.110954Z","iopub.status.idle":"2022-05-26T18:24:20.51506Z","shell.execute_reply.started":"2022-05-26T18:24:15.110909Z","shell.execute_reply":"2022-05-26T18:24:20.514295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"PATH = '/kaggle/working/train'\nfilename = os.listdir(PATH)\nIMG_SIZE = 100\n\nplt.figure(figsize=(10,10))\nfor i in range(1, 7):\n    img_array = cv2.imread(os.path.join(PATH, filename[i]))\n    resize_image = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))\n    plt.subplot(3,3, i)\n    image = cv2.cvtColor(resize_image, cv2.COLOR_BGR2RGB)\n    #plt.figure()\n    plt.axis('off')\n    plt.imshow(image)    ","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:20.51617Z","iopub.execute_input":"2022-05-26T18:24:20.516412Z","iopub.status.idle":"2022-05-26T18:24:20.982976Z","shell.execute_reply.started":"2022-05-26T18:24:20.516376Z","shell.execute_reply":"2022-05-26T18:24:20.981431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ntraining_data = []\nIMG_SIZE = 100\npath = '/kaggle/working/train'\nfilenames = os.listdir('/kaggle/working/train')\nfor img in tqdm(filenames):\n    try:\n        if img.find('cat') == -1:\n            category = 0\n        else:\n            category = 1\n        \n        img_array = cv2.imread(os.path.join(path, img), cv2.IMREAD_GRAYSCALE)\n        new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))\n        training_data.append([new_array, category])\n    except Exception as e:\n        pass\n","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:20.98397Z","iopub.execute_input":"2022-05-26T18:24:20.984184Z","iopub.status.idle":"2022-05-26T18:24:45.815041Z","shell.execute_reply.started":"2022-05-26T18:24:20.984156Z","shell.execute_reply":"2022-05-26T18:24:45.814315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10,10))\nfor i in range(1, 7):\n    plt.subplot(3,3,i)\n    plt.axis('off')\n    if training_data[10+i][1] == 0:\n        plt.title('Dog')\n    else:\n        plt.title('Cat')\n    plt.imshow(training_data[10+i][0], cmap='gray_r')","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:45.819102Z","iopub.execute_input":"2022-05-26T18:24:45.819893Z","iopub.status.idle":"2022-05-26T18:24:46.329253Z","shell.execute_reply.started":"2022-05-26T18:24:45.819846Z","shell.execute_reply":"2022-05-26T18:24:46.328494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testing_data = []\nIMG_SIZE = 100\n\npath = '/kaggle/working/test'\nfilenames = os.listdir('/kaggle/working/test')\nfor img in tqdm(filenames):\n    try:        \n        img_array = cv2.imread(os.path.join(path, img), cv2.IMREAD_GRAYSCALE)\n        new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))\n        testing_data.append([new_array])\n    except Exception as e:\n        pass","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:46.332897Z","iopub.execute_input":"2022-05-26T18:24:46.333425Z","iopub.status.idle":"2022-05-26T18:24:57.940564Z","shell.execute_reply.started":"2022-05-26T18:24:46.333382Z","shell.execute_reply":"2022-05-26T18:24:57.939867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(training_data)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:57.941758Z","iopub.execute_input":"2022-05-26T18:24:57.942094Z","iopub.status.idle":"2022-05-26T18:24:57.947296Z","shell.execute_reply.started":"2022-05-26T18:24:57.942047Z","shell.execute_reply":"2022-05-26T18:24:57.946586Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"random.shuffle(training_data)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:57.948675Z","iopub.execute_input":"2022-05-26T18:24:57.949076Z","iopub.status.idle":"2022-05-26T18:24:57.980597Z","shell.execute_reply.started":"2022-05-26T18:24:57.949038Z","shell.execute_reply":"2022-05-26T18:24:57.979973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nX = []\ny = []\n\nfor features, label  in training_data:\n    X.append(features)\n    y.append(label)\n    \nX = np.array(X).reshape(-1, IMG_SIZE, IMG_SIZE, 1)\n","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:57.981668Z","iopub.execute_input":"2022-05-26T18:24:57.981882Z","iopub.status.idle":"2022-05-26T18:24:58.098127Z","shell.execute_reply.started":"2022-05-26T18:24:57.981848Z","shell.execute_reply":"2022-05-26T18:24:58.097366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\npickle_out =open(\"X.pickle\", \"wb\")\npickle.dump(X, pickle_out)\npickle_out.close()\n\npickle_out = open(\"y.pickle\", \"wb\")\npickle.dump(y, pickle_out)\npickle_out.close()\n","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:58.099226Z","iopub.execute_input":"2022-05-26T18:24:58.099469Z","iopub.status.idle":"2022-05-26T18:24:58.468684Z","shell.execute_reply.started":"2022-05-26T18:24:58.099437Z","shell.execute_reply":"2022-05-26T18:24:58.467935Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pickle_in = open(\"X.pickle\", \"rb\")\nX = pickle.load(pickle_in)\n\npickle_in = open(\"y.pickle\", \"rb\")\ny = pickle.load(pickle_in)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:58.469826Z","iopub.execute_input":"2022-05-26T18:24:58.47029Z","iopub.status.idle":"2022-05-26T18:24:58.7961Z","shell.execute_reply.started":"2022-05-26T18:24:58.470252Z","shell.execute_reply":"2022-05-26T18:24:58.795352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = X/255.0\n\nX = np.array(X)\ny = np.array(y)\n","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:24:58.797243Z","iopub.execute_input":"2022-05-26T18:24:58.797495Z","iopub.status.idle":"2022-05-26T18:25:00.116069Z","shell.execute_reply.started":"2022-05-26T18:24:58.797462Z","shell.execute_reply":"2022-05-26T18:25:00.115338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(X)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:25:00.117526Z","iopub.execute_input":"2022-05-26T18:25:00.117802Z","iopub.status.idle":"2022-05-26T18:25:00.123163Z","shell.execute_reply.started":"2022-05-26T18:25:00.117767Z","shell.execute_reply":"2022-05-26T18:25:00.122403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(y)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:25:00.124751Z","iopub.execute_input":"2022-05-26T18:25:00.125273Z","iopub.status.idle":"2022-05-26T18:25:00.134376Z","shell.execute_reply.started":"2022-05-26T18:25:00.125239Z","shell.execute_reply":"2022-05-26T18:25:00.133741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, x_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state=50)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:25:00.135319Z","iopub.execute_input":"2022-05-26T18:25:00.135531Z","iopub.status.idle":"2022-05-26T18:25:00.714709Z","shell.execute_reply.started":"2022-05-26T18:25:00.135508Z","shell.execute_reply":"2022-05-26T18:25:00.713952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(X_train)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:25:00.716149Z","iopub.execute_input":"2022-05-26T18:25:00.716403Z","iopub.status.idle":"2022-05-26T18:25:00.721523Z","shell.execute_reply.started":"2022-05-26T18:25:00.716369Z","shell.execute_reply":"2022-05-26T18:25:00.720896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(y_train)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:25:00.722954Z","iopub.execute_input":"2022-05-26T18:25:00.723437Z","iopub.status.idle":"2022-05-26T18:25:00.731635Z","shell.execute_reply.started":"2022-05-26T18:25:00.723399Z","shell.execute_reply":"2022-05-26T18:25:00.730891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = Sequential()\n\nmodel.add(Conv2D(256, (3,3), input_shape=X_train.shape[1:]))\nmodel.add(Activation('relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(256, (3,3), input_shape=X_train.shape[1:]))\nmodel.add(Activation('relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(512, (3,3)))\nmodel.add(Activation('relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(1024, (3,3)))\nmodel.add(Activation('relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(1024, (3,3)))\nmodel.add(Activation('relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Flatten()) # this converts our 3D feature maps to 1D feature vectors\n\nmodel.add(Dense(64))\nmodel.add(Dense(1))\n\nmodel.add(Activation('sigmoid'))\n","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:46:40.693255Z","iopub.execute_input":"2022-05-26T18:46:40.69351Z","iopub.status.idle":"2022-05-26T18:46:40.784329Z","shell.execute_reply.started":"2022-05-26T18:46:40.693481Z","shell.execute_reply":"2022-05-26T18:46:40.783655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.summary()","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:46:42.256051Z","iopub.execute_input":"2022-05-26T18:46:42.256313Z","iopub.status.idle":"2022-05-26T18:46:42.272094Z","shell.execute_reply.started":"2022-05-26T18:46:42.256283Z","shell.execute_reply":"2022-05-26T18:46:42.271381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'],)\n\nhistory = model.fit(X_train, y_train, batch_size=32, epochs=30, validation_data = (x_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-05-26T18:47:40.397824Z","iopub.execute_input":"2022-05-26T18:47:40.398574Z","iopub.status.idle":"2022-05-26T19:03:05.066967Z","shell.execute_reply.started":"2022-05-26T18:47:40.398529Z","shell.execute_reply":"2022-05-26T19:03:05.066139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"score = model.evaluate(x_test, y_test, verbose=0)\nprint('Test Loss:', score[0])\nprint('Test accuracy:', score[1])","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:03:09.376192Z","iopub.execute_input":"2022-05-26T19:03:09.376521Z","iopub.status.idle":"2022-05-26T19:03:13.672306Z","shell.execute_reply.started":"2022-05-26T19:03:09.376481Z","shell.execute_reply":"2022-05-26T19:03:13.670782Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plotting our loss charts\n# Use the history object we created to get our saved perormace result.\nhistory_dict = history.history\n\n# Extract the loss and validation losses\nloss_values = history_dict['loss']\nval_loss_values = history_dict['val_loss']\n\nepochs = range(1, len(loss_values)+1)\n\nline1 = plt.plot(epochs, val_loss_values, label ='Validation/Test Loss')\nline2 = plt.plot(epochs, loss_values, label='Training Loss')\nplt.setp(line1, linewidth = 2.0, marker='+', markersize=10.0)\nplt.setp(line2, linewidth=2.0, marker='4', markersize=10.0)\nplt.legend()\nplt.grid(True)\nplt.savefig('model_loss.png')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:03:26.585326Z","iopub.execute_input":"2022-05-26T19:03:26.58567Z","iopub.status.idle":"2022-05-26T19:03:26.964416Z","shell.execute_reply.started":"2022-05-26T19:03:26.585597Z","shell.execute_reply":"2022-05-26T19:03:26.963738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Accuracy Charts","metadata":{}},{"cell_type":"code","source":"history_dict = history.history\n\nacc_values = history_dict['accuracy']\nval_acc_values = history_dict['val_accuracy']\nepochs = range(1, len(loss_values)+1)\n\nline1 = plt.plot(epochs, val_loss_values, label='Validation/Test Accuracy')\nline2 = plt.plot(epochs, acc_values, label ='Training Accuracy')\n\nplt.setp(line1, linewidth=2.0, marker='+', markersize=10.0)\nplt.setp(line2, linewidth=2.0, marker='4', markersize=10.0)\nplt.xlabel('Epochs')\nplt.ylabel('Accuracy')\nplt.grid(True)\nplt.legend()\nplt.savefig('model_accuracy.png')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:03:30.547929Z","iopub.execute_input":"2022-05-26T19:03:30.548476Z","iopub.status.idle":"2022-05-26T19:03:30.814566Z","shell.execute_reply.started":"2022-05-26T19:03:30.548437Z","shell.execute_reply":"2022-05-26T19:03:30.813529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IMG_SIZE = 100\ntest = []\n\nfor features  in testing_data:\n    test.append(features)\n    \ntest = np.array(test).reshape(-1, IMG_SIZE, IMG_SIZE, 1)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:04.418013Z","iopub.execute_input":"2022-05-26T19:04:04.418276Z","iopub.status.idle":"2022-05-26T19:04:04.511392Z","shell.execute_reply.started":"2022-05-26T19:04:04.418248Z","shell.execute_reply":"2022-05-26T19:04:04.51066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test/255.0\n\ntest = np.array(test)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:04.675438Z","iopub.execute_input":"2022-05-26T19:04:04.675668Z","iopub.status.idle":"2022-05-26T19:04:05.846472Z","shell.execute_reply.started":"2022-05-26T19:04:04.675639Z","shell.execute_reply":"2022-05-26T19:04:05.845677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = model.predict(test) ","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:05.848343Z","iopub.execute_input":"2022-05-26T19:04:05.848636Z","iopub.status.idle":"2022-05-26T19:04:12.974944Z","shell.execute_reply.started":"2022-05-26T19:04:05.848585Z","shell.execute_reply":"2022-05-26T19:04:12.974175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#predict_xtest = model.predict(x_test) ","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:12.976717Z","iopub.execute_input":"2022-05-26T19:04:12.976966Z","iopub.status.idle":"2022-05-26T19:04:12.980706Z","shell.execute_reply.started":"2022-05-26T19:04:12.976932Z","shell.execute_reply":"2022-05-26T19:04:12.979767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#predict_xtest ","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:12.981972Z","iopub.execute_input":"2022-05-26T19:04:12.98236Z","iopub.status.idle":"2022-05-26T19:04:12.990496Z","shell.execute_reply.started":"2022-05-26T19:04:12.982325Z","shell.execute_reply":"2022-05-26T19:04:12.989894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:12.993419Z","iopub.execute_input":"2022-05-26T19:04:12.993665Z","iopub.status.idle":"2022-05-26T19:04:13.000889Z","shell.execute_reply.started":"2022-05-26T19:04:12.993634Z","shell.execute_reply":"2022-05-26T19:04:13.000165Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction.shape","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:13.002392Z","iopub.execute_input":"2022-05-26T19:04:13.002669Z","iopub.status.idle":"2022-05-26T19:04:13.011765Z","shell.execute_reply.started":"2022-05-26T19:04:13.002635Z","shell.execute_reply":"2022-05-26T19:04:13.011109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission = pd.read_csv('/kaggle/input/dogs-vs-cats-redux-kernels-edition/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:13.012864Z","iopub.execute_input":"2022-05-26T19:04:13.013166Z","iopub.status.idle":"2022-05-26T19:04:13.02879Z","shell.execute_reply.started":"2022-05-26T19:04:13.013132Z","shell.execute_reply":"2022-05-26T19:04:13.028139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:14.48427Z","iopub.execute_input":"2022-05-26T19:04:14.484829Z","iopub.status.idle":"2022-05-26T19:04:14.494442Z","shell.execute_reply.started":"2022-05-26T19:04:14.484787Z","shell.execute_reply":"2022-05-26T19:04:14.493636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission['label'] = prediction","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:15.342711Z","iopub.execute_input":"2022-05-26T19:04:15.343374Z","iopub.status.idle":"2022-05-26T19:04:15.348282Z","shell.execute_reply.started":"2022-05-26T19:04:15.343336Z","shell.execute_reply":"2022-05-26T19:04:15.347436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission['label'] = my_submission['label'].map(lambda x: 1 if x >= 0.5 else 0 )","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:16.078451Z","iopub.execute_input":"2022-05-26T19:04:16.079054Z","iopub.status.idle":"2022-05-26T19:04:16.092182Z","shell.execute_reply.started":"2022-05-26T19:04:16.079018Z","shell.execute_reply":"2022-05-26T19:04:16.091377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:16.789048Z","iopub.execute_input":"2022-05-26T19:04:16.789325Z","iopub.status.idle":"2022-05-26T19:04:16.797413Z","shell.execute_reply.started":"2022-05-26T19:04:16.789297Z","shell.execute_reply":"2022-05-26T19:04:16.796477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission['label'] = my_submission['label'].round(1)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:19.37626Z","iopub.execute_input":"2022-05-26T19:04:19.376523Z","iopub.status.idle":"2022-05-26T19:04:19.382718Z","shell.execute_reply.started":"2022-05-26T19:04:19.376493Z","shell.execute_reply":"2022-05-26T19:04:19.380583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission.to_csv('my_submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:04:19.697314Z","iopub.execute_input":"2022-05-26T19:04:19.697949Z","iopub.status.idle":"2022-05-26T19:04:19.722639Z","shell.execute_reply.started":"2022-05-26T19:04:19.697914Z","shell.execute_reply":"2022-05-26T19:04:19.721995Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.save(\"model.h5\")","metadata":{"execution":{"iopub.status.busy":"2022-05-26T19:06:37.92342Z","iopub.execute_input":"2022-05-26T19:06:37.924293Z","iopub.status.idle":"2022-05-26T19:06:38.322644Z","shell.execute_reply.started":"2022-05-26T19:06:37.924254Z","shell.execute_reply":"2022-05-26T19:06:38.3219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}