{"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-05T10:01:56.851882Z","iopub.execute_input":"2022-05-05T10:01:56.852216Z","iopub.status.idle":"2022-05-05T10:01:56.884940Z","shell.execute_reply.started":"2022-05-05T10:01:56.852140Z","shell.execute_reply":"2022-05-05T10:01:56.884290Z"},"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-05T10:01:56.886457Z","iopub.execute_input":"2022-05-05T10:01:56.886717Z","iopub.status.idle":"2022-05-05T10:01:57.810186Z","shell.execute_reply.started":"2022-05-05T10:01:56.886684Z","shell.execute_reply":"2022-05-05T10:01:57.809488Z"},"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-05T10:01:57.811479Z","iopub.execute_input":"2022-05-05T10:01:57.811904Z","iopub.status.idle":"2022-05-05T10:01:58.108086Z","shell.execute_reply.started":"2022-05-05T10:01:57.811867Z","shell.execute_reply":"2022-05-05T10:01:58.107376Z"},"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-05T10:01:58.110034Z","iopub.execute_input":"2022-05-05T10:01:58.110220Z","iopub.status.idle":"2022-05-05T10:02:03.432077Z","shell.execute_reply.started":"2022-05-05T10:01:58.110197Z","shell.execute_reply":"2022-05-05T10:02:03.431344Z"},"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-05T10:02:03.434356Z","iopub.execute_input":"2022-05-05T10:02:03.434992Z","iopub.status.idle":"2022-05-05T10:02:14.635748Z","shell.execute_reply.started":"2022-05-05T10:02:03.434950Z","shell.execute_reply":"2022-05-05T10:02:14.635023Z"},"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-05T10:02:14.636952Z","iopub.execute_input":"2022-05-05T10:02:14.637208Z","iopub.status.idle":"2022-05-05T10:02:19.881787Z","shell.execute_reply.started":"2022-05-05T10:02:14.637171Z","shell.execute_reply":"2022-05-05T10:02:19.881030Z"},"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-05T10:02:19.883017Z","iopub.execute_input":"2022-05-05T10:02:19.883513Z","iopub.status.idle":"2022-05-05T10:02:20.357306Z","shell.execute_reply.started":"2022-05-05T10:02:19.883473Z","shell.execute_reply":"2022-05-05T10:02:20.356702Z"},"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-05T10:02:20.358215Z","iopub.execute_input":"2022-05-05T10:02:20.358440Z","iopub.status.idle":"2022-05-05T10:02:44.117980Z","shell.execute_reply.started":"2022-05-05T10:02:20.358410Z","shell.execute_reply":"2022-05-05T10:02:44.117263Z"},"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-05T10:02:44.121285Z","iopub.execute_input":"2022-05-05T10:02:44.121486Z","iopub.status.idle":"2022-05-05T10:02:44.499363Z","shell.execute_reply.started":"2022-05-05T10:02:44.121460Z","shell.execute_reply":"2022-05-05T10:02:44.498764Z"},"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-05T10:02:44.500517Z","iopub.execute_input":"2022-05-05T10:02:44.500899Z","iopub.status.idle":"2022-05-05T10:02:55.950766Z","shell.execute_reply.started":"2022-05-05T10:02:44.500864Z","shell.execute_reply":"2022-05-05T10:02:55.950078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(training_data)","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:02:55.952090Z","iopub.execute_input":"2022-05-05T10:02:55.952492Z","iopub.status.idle":"2022-05-05T10:02:55.957894Z","shell.execute_reply.started":"2022-05-05T10:02:55.952454Z","shell.execute_reply":"2022-05-05T10:02:55.957174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"random.shuffle(training_data)","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:02:55.959284Z","iopub.execute_input":"2022-05-05T10:02:55.959725Z","iopub.status.idle":"2022-05-05T10:02:55.991596Z","shell.execute_reply.started":"2022-05-05T10:02:55.959685Z","shell.execute_reply":"2022-05-05T10:02:55.990842Z"},"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-05T10:02:55.993706Z","iopub.execute_input":"2022-05-05T10:02:55.994111Z","iopub.status.idle":"2022-05-05T10:02:56.109372Z","shell.execute_reply.started":"2022-05-05T10:02:55.994078Z","shell.execute_reply":"2022-05-05T10:02:56.108617Z"},"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-05T10:02:56.110623Z","iopub.execute_input":"2022-05-05T10:02:56.110875Z","iopub.status.idle":"2022-05-05T10:02:56.483340Z","shell.execute_reply.started":"2022-05-05T10:02:56.110842Z","shell.execute_reply":"2022-05-05T10:02:56.482611Z"},"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-05T10:02:56.484767Z","iopub.execute_input":"2022-05-05T10:02:56.485020Z","iopub.status.idle":"2022-05-05T10:02:56.812202Z","shell.execute_reply.started":"2022-05-05T10:02:56.484982Z","shell.execute_reply":"2022-05-05T10:02:56.811443Z"},"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-05T10:02:56.813664Z","iopub.execute_input":"2022-05-05T10:02:56.813930Z","iopub.status.idle":"2022-05-05T10:02:58.286539Z","shell.execute_reply.started":"2022-05-05T10:02:56.813895Z","shell.execute_reply":"2022-05-05T10:02:58.285821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(X)","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:02:58.287805Z","iopub.execute_input":"2022-05-05T10:02:58.288041Z","iopub.status.idle":"2022-05-05T10:02:58.294087Z","shell.execute_reply.started":"2022-05-05T10:02:58.288010Z","shell.execute_reply":"2022-05-05T10:02:58.292644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(y)","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:02:58.295536Z","iopub.execute_input":"2022-05-05T10:02:58.296127Z","iopub.status.idle":"2022-05-05T10:02:58.303559Z","shell.execute_reply.started":"2022-05-05T10:02:58.296084Z","shell.execute_reply":"2022-05-05T10:02:58.302820Z"},"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-05T10:02:58.304822Z","iopub.execute_input":"2022-05-05T10:02:58.305246Z","iopub.status.idle":"2022-05-05T10:02:58.887305Z","shell.execute_reply.started":"2022-05-05T10:02:58.305210Z","shell.execute_reply":"2022-05-05T10:02:58.886584Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(X_train)","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:02:58.889610Z","iopub.execute_input":"2022-05-05T10:02:58.890018Z","iopub.status.idle":"2022-05-05T10:02:58.895268Z","shell.execute_reply.started":"2022-05-05T10:02:58.889980Z","shell.execute_reply":"2022-05-05T10:02:58.894605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(y_train)","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:02:58.896628Z","iopub.execute_input":"2022-05-05T10:02:58.897051Z","iopub.status.idle":"2022-05-05T10:02:58.905640Z","shell.execute_reply.started":"2022-05-05T10:02:58.897012Z","shell.execute_reply":"2022-05-05T10:02:58.904796Z"},"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)))\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-05T10:02:58.908032Z","iopub.execute_input":"2022-05-05T10:02:58.908463Z","iopub.status.idle":"2022-05-05T10:03:01.379958Z","shell.execute_reply.started":"2022-05-05T10:02:58.908422Z","shell.execute_reply":"2022-05-05T10:03:01.379237Z"},"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=15, validation_data = (x_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:03:01.380991Z","iopub.execute_input":"2022-05-05T10:03:01.381819Z","iopub.status.idle":"2022-05-05T10:08:25.376002Z","shell.execute_reply.started":"2022-05-05T10:03:01.381780Z","shell.execute_reply":"2022-05-05T10:08:25.375244Z"},"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-05T10:08:25.380507Z","iopub.execute_input":"2022-05-05T10:08:25.380747Z","iopub.status.idle":"2022-05-05T10:08:28.753827Z","shell.execute_reply.started":"2022-05-05T10:08:25.380719Z","shell.execute_reply":"2022-05-05T10:08:28.752285Z"},"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.show()","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:28.755034Z","iopub.execute_input":"2022-05-05T10:08:28.755278Z","iopub.status.idle":"2022-05-05T10:08:28.963371Z","shell.execute_reply.started":"2022-05-05T10:08:28.755244Z","shell.execute_reply":"2022-05-05T10:08:28.962732Z"},"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.show()","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:28.964674Z","iopub.execute_input":"2022-05-05T10:08:28.964910Z","iopub.status.idle":"2022-05-05T10:08:29.187061Z","shell.execute_reply.started":"2022-05-05T10:08:28.964881Z","shell.execute_reply":"2022-05-05T10:08:29.186404Z"},"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-05T10:08:29.188460Z","iopub.execute_input":"2022-05-05T10:08:29.188955Z","iopub.status.idle":"2022-05-05T10:08:29.251006Z","shell.execute_reply.started":"2022-05-05T10:08:29.188915Z","shell.execute_reply":"2022-05-05T10:08:29.250219Z"},"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-05T10:08:29.252190Z","iopub.execute_input":"2022-05-05T10:08:29.253951Z","iopub.status.idle":"2022-05-05T10:08:31.088721Z","shell.execute_reply.started":"2022-05-05T10:08:29.253909Z","shell.execute_reply":"2022-05-05T10:08:31.087972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = model.predict(test) ","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:31.089865Z","iopub.execute_input":"2022-05-05T10:08:31.090125Z","iopub.status.idle":"2022-05-05T10:08:36.200130Z","shell.execute_reply.started":"2022-05-05T10:08:31.090092Z","shell.execute_reply":"2022-05-05T10:08:36.199363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#predict_xtest = model.predict(x_test) ","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:36.201521Z","iopub.execute_input":"2022-05-05T10:08:36.201816Z","iopub.status.idle":"2022-05-05T10:08:36.207652Z","shell.execute_reply.started":"2022-05-05T10:08:36.201779Z","shell.execute_reply":"2022-05-05T10:08:36.205297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#predict_xtest ","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:36.208835Z","iopub.execute_input":"2022-05-05T10:08:36.209116Z","iopub.status.idle":"2022-05-05T10:08:36.220236Z","shell.execute_reply.started":"2022-05-05T10:08:36.209068Z","shell.execute_reply":"2022-05-05T10:08:36.219523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:36.221388Z","iopub.execute_input":"2022-05-05T10:08:36.221660Z","iopub.status.idle":"2022-05-05T10:08:36.233028Z","shell.execute_reply.started":"2022-05-05T10:08:36.221615Z","shell.execute_reply":"2022-05-05T10:08:36.232240Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction.shape","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:36.234720Z","iopub.execute_input":"2022-05-05T10:08:36.235353Z","iopub.status.idle":"2022-05-05T10:08:36.242977Z","shell.execute_reply.started":"2022-05-05T10:08:36.235314Z","shell.execute_reply":"2022-05-05T10:08:36.242230Z"},"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-05T10:08:36.244137Z","iopub.execute_input":"2022-05-05T10:08:36.244471Z","iopub.status.idle":"2022-05-05T10:08:36.291737Z","shell.execute_reply.started":"2022-05-05T10:08:36.244434Z","shell.execute_reply":"2022-05-05T10:08:36.291082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:36.293074Z","iopub.execute_input":"2022-05-05T10:08:36.293334Z","iopub.status.idle":"2022-05-05T10:08:36.310296Z","shell.execute_reply.started":"2022-05-05T10:08:36.293300Z","shell.execute_reply":"2022-05-05T10:08:36.309604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission['label'] = prediction","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:36.311535Z","iopub.execute_input":"2022-05-05T10:08:36.311817Z","iopub.status.idle":"2022-05-05T10:08:36.321215Z","shell.execute_reply.started":"2022-05-05T10:08:36.311783Z","shell.execute_reply":"2022-05-05T10:08:36.320443Z"},"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-05T10:08:36.322684Z","iopub.execute_input":"2022-05-05T10:08:36.322983Z","iopub.status.idle":"2022-05-05T10:08:36.338558Z","shell.execute_reply.started":"2022-05-05T10:08:36.322926Z","shell.execute_reply":"2022-05-05T10:08:36.337709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-05T10:08:36.339819Z","iopub.execute_input":"2022-05-05T10:08:36.340070Z","iopub.status.idle":"2022-05-05T10:08:36.353205Z","shell.execute_reply.started":"2022-05-05T10:08:36.340035Z","shell.execute_reply":"2022-05-05T10:08:36.352394Z"},"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-05T10:08:36.354638Z","iopub.execute_input":"2022-05-05T10:08:36.355141Z","iopub.status.idle":"2022-05-05T10:08:36.360989Z","shell.execute_reply.started":"2022-05-05T10:08:36.355092Z","shell.execute_reply":"2022-05-05T10:08:36.360289Z"},"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-05T10:08:36.362152Z","iopub.execute_input":"2022-05-05T10:08:36.362535Z","iopub.status.idle":"2022-05-05T10:08:36.391623Z","shell.execute_reply.started":"2022-05-05T10:08:36.362497Z","shell.execute_reply":"2022-05-05T10:08:36.390981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}