{"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":"2023-07-28T07:28:42.735822Z","iopub.execute_input":"2023-07-28T07:28:42.736151Z","iopub.status.idle":"2023-07-28T07:28:42.765777Z","shell.execute_reply.started":"2023-07-28T07:28:42.736062Z","shell.execute_reply":"2023-07-28T07:28:42.765036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:28:42.767588Z","iopub.execute_input":"2023-07-28T07:28:42.767866Z","iopub.status.idle":"2023-07-28T07:28:43.674613Z","shell.execute_reply.started":"2023-07-28T07:28:42.767830Z","shell.execute_reply":"2023-07-28T07:28:43.673646Z"},"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":"2023-07-28T07:28:43.676218Z","iopub.execute_input":"2023-07-28T07:28:43.676497Z","iopub.status.idle":"2023-07-28T07:28:43.929014Z","shell.execute_reply.started":"2023-07-28T07:28:43.676458Z","shell.execute_reply":"2023-07-28T07:28:43.928239Z"},"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":"2023-07-28T07:28:43.931974Z","iopub.execute_input":"2023-07-28T07:28:43.932461Z","iopub.status.idle":"2023-07-28T07:28:49.051875Z","shell.execute_reply.started":"2023-07-28T07:28:43.932419Z","shell.execute_reply":"2023-07-28T07:28:49.051001Z"},"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":"2023-07-28T07:28:49.053392Z","iopub.execute_input":"2023-07-28T07:28:49.053812Z","iopub.status.idle":"2023-07-28T07:29:02.259658Z","shell.execute_reply.started":"2023-07-28T07:28:49.053773Z","shell.execute_reply":"2023-07-28T07:29:02.258763Z"},"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":"2023-07-28T07:29:02.260993Z","iopub.execute_input":"2023-07-28T07:29:02.261330Z","iopub.status.idle":"2023-07-28T07:29:08.681465Z","shell.execute_reply.started":"2023-07-28T07:29:02.261281Z","shell.execute_reply":"2023-07-28T07:29:08.680616Z"},"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":"2023-07-28T07:29:08.682986Z","iopub.execute_input":"2023-07-28T07:29:08.683906Z","iopub.status.idle":"2023-07-28T07:29:09.215363Z","shell.execute_reply.started":"2023-07-28T07:29:08.683864Z","shell.execute_reply":"2023-07-28T07:29:09.214686Z"},"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":"2023-07-28T07:29:09.216417Z","iopub.execute_input":"2023-07-28T07:29:09.216658Z","iopub.status.idle":"2023-07-28T07:29:34.330426Z","shell.execute_reply.started":"2023-07-28T07:29:09.216626Z","shell.execute_reply":"2023-07-28T07:29:34.329531Z"},"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":"2023-07-28T07:29:34.331759Z","iopub.execute_input":"2023-07-28T07:29:34.332579Z","iopub.status.idle":"2023-07-28T07:29:34.785612Z","shell.execute_reply.started":"2023-07-28T07:29:34.332534Z","shell.execute_reply":"2023-07-28T07:29:34.784887Z"},"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":"2023-07-28T07:29:34.789003Z","iopub.execute_input":"2023-07-28T07:29:34.789553Z","iopub.status.idle":"2023-07-28T07:29:46.901094Z","shell.execute_reply.started":"2023-07-28T07:29:34.789514Z","shell.execute_reply":"2023-07-28T07:29:46.900232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(training_data)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:29:46.902684Z","iopub.execute_input":"2023-07-28T07:29:46.902976Z","iopub.status.idle":"2023-07-28T07:29:46.910100Z","shell.execute_reply.started":"2023-07-28T07:29:46.902937Z","shell.execute_reply":"2023-07-28T07:29:46.908774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"random.shuffle(training_data)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:29:46.911882Z","iopub.execute_input":"2023-07-28T07:29:46.912157Z","iopub.status.idle":"2023-07-28T07:29:46.951437Z","shell.execute_reply.started":"2023-07-28T07:29:46.912120Z","shell.execute_reply":"2023-07-28T07:29:46.950728Z"},"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":"2023-07-28T07:29:46.952494Z","iopub.execute_input":"2023-07-28T07:29:46.952731Z","iopub.status.idle":"2023-07-28T07:29:47.071585Z","shell.execute_reply.started":"2023-07-28T07:29:46.952692Z","shell.execute_reply":"2023-07-28T07:29:47.070655Z"},"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":"2023-07-28T07:29:47.072924Z","iopub.execute_input":"2023-07-28T07:29:47.073453Z","iopub.status.idle":"2023-07-28T07:29:47.486175Z","shell.execute_reply.started":"2023-07-28T07:29:47.073410Z","shell.execute_reply":"2023-07-28T07:29:47.485285Z"},"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":"2023-07-28T07:29:47.487736Z","iopub.execute_input":"2023-07-28T07:29:47.488018Z","iopub.status.idle":"2023-07-28T07:29:47.863474Z","shell.execute_reply.started":"2023-07-28T07:29:47.487977Z","shell.execute_reply":"2023-07-28T07:29:47.861205Z"},"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":"2023-07-28T07:29:47.865767Z","iopub.execute_input":"2023-07-28T07:29:47.866262Z","iopub.status.idle":"2023-07-28T07:29:49.229973Z","shell.execute_reply.started":"2023-07-28T07:29:47.866219Z","shell.execute_reply":"2023-07-28T07:29:49.229076Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(X)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:29:49.231339Z","iopub.execute_input":"2023-07-28T07:29:49.232145Z","iopub.status.idle":"2023-07-28T07:29:49.239636Z","shell.execute_reply.started":"2023-07-28T07:29:49.232099Z","shell.execute_reply":"2023-07-28T07:29:49.238605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(y)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:29:49.241262Z","iopub.execute_input":"2023-07-28T07:29:49.242250Z","iopub.status.idle":"2023-07-28T07:29:49.249854Z","shell.execute_reply.started":"2023-07-28T07:29:49.242184Z","shell.execute_reply":"2023-07-28T07:29:49.249070Z"},"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.2, random_state=50)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:29:49.251463Z","iopub.execute_input":"2023-07-28T07:29:49.252303Z","iopub.status.idle":"2023-07-28T07:29:49.847974Z","shell.execute_reply.started":"2023-07-28T07:29:49.252138Z","shell.execute_reply":"2023-07-28T07:29:49.847110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(X_train)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:29:49.849347Z","iopub.execute_input":"2023-07-28T07:29:49.849811Z","iopub.status.idle":"2023-07-28T07:29:49.857038Z","shell.execute_reply.started":"2023-07-28T07:29:49.849764Z","shell.execute_reply":"2023-07-28T07:29:49.856132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(y_train)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:29:49.858675Z","iopub.execute_input":"2023-07-28T07:29:49.858956Z","iopub.status.idle":"2023-07-28T07:29:49.867957Z","shell.execute_reply.started":"2023-07-28T07:29:49.858918Z","shell.execute_reply":"2023-07-28T07:29:49.867112Z"},"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":"2023-07-28T07:29:49.869515Z","iopub.execute_input":"2023-07-28T07:29:49.869780Z","iopub.status.idle":"2023-07-28T07:29:52.577580Z","shell.execute_reply.started":"2023-07-28T07:29:49.869744Z","shell.execute_reply":"2023-07-28T07:29:52.576767Z"},"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":"2023-07-28T07:29:52.579033Z","iopub.execute_input":"2023-07-28T07:29:52.579342Z","iopub.status.idle":"2023-07-28T07:35:08.782378Z","shell.execute_reply.started":"2023-07-28T07:29:52.579290Z","shell.execute_reply":"2023-07-28T07:35:08.781599Z"},"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":"2023-07-28T07:35:08.784004Z","iopub.execute_input":"2023-07-28T07:35:08.784462Z","iopub.status.idle":"2023-07-28T07:35:11.119635Z","shell.execute_reply.started":"2023-07-28T07:35:08.784422Z","shell.execute_reply":"2023-07-28T07:35:11.118737Z"},"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":"2023-07-28T07:35:11.121157Z","iopub.execute_input":"2023-07-28T07:35:11.121446Z","iopub.status.idle":"2023-07-28T07:35:11.414680Z","shell.execute_reply.started":"2023-07-28T07:35:11.121406Z","shell.execute_reply":"2023-07-28T07:35:11.413929Z"},"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":"2023-07-28T07:35:11.416322Z","iopub.execute_input":"2023-07-28T07:35:11.416853Z","iopub.status.idle":"2023-07-28T07:35:11.681543Z","shell.execute_reply.started":"2023-07-28T07:35:11.416801Z","shell.execute_reply":"2023-07-28T07:35:11.680805Z"},"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":"2023-07-28T07:35:11.683149Z","iopub.execute_input":"2023-07-28T07:35:11.683662Z","iopub.status.idle":"2023-07-28T07:35:11.747061Z","shell.execute_reply.started":"2023-07-28T07:35:11.683619Z","shell.execute_reply":"2023-07-28T07:35:11.746167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test/255.0\n\ntest = np.array(test)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:11.751497Z","iopub.execute_input":"2023-07-28T07:35:11.751734Z","iopub.status.idle":"2023-07-28T07:35:14.569112Z","shell.execute_reply.started":"2023-07-28T07:35:11.751704Z","shell.execute_reply":"2023-07-28T07:35:14.568257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = model.predict(test) ","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:14.570482Z","iopub.execute_input":"2023-07-28T07:35:14.570749Z","iopub.status.idle":"2023-07-28T07:35:21.078328Z","shell.execute_reply.started":"2023-07-28T07:35:14.570708Z","shell.execute_reply":"2023-07-28T07:35:21.077476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#predict_xtest = model.predict(x_test) ","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.079896Z","iopub.execute_input":"2023-07-28T07:35:21.080179Z","iopub.status.idle":"2023-07-28T07:35:21.084836Z","shell.execute_reply.started":"2023-07-28T07:35:21.080141Z","shell.execute_reply":"2023-07-28T07:35:21.084012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#predict_xtest ","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.086566Z","iopub.execute_input":"2023-07-28T07:35:21.087378Z","iopub.status.idle":"2023-07-28T07:35:21.093292Z","shell.execute_reply.started":"2023-07-28T07:35:21.087326Z","shell.execute_reply":"2023-07-28T07:35:21.092554Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.094799Z","iopub.execute_input":"2023-07-28T07:35:21.095149Z","iopub.status.idle":"2023-07-28T07:35:21.104117Z","shell.execute_reply.started":"2023-07-28T07:35:21.095114Z","shell.execute_reply":"2023-07-28T07:35:21.103187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction.shape","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.105452Z","iopub.execute_input":"2023-07-28T07:35:21.106072Z","iopub.status.idle":"2023-07-28T07:35:21.114367Z","shell.execute_reply.started":"2023-07-28T07:35:21.106010Z","shell.execute_reply":"2023-07-28T07:35:21.113425Z"},"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":"2023-07-28T07:35:21.116055Z","iopub.execute_input":"2023-07-28T07:35:21.116519Z","iopub.status.idle":"2023-07-28T07:35:21.157749Z","shell.execute_reply.started":"2023-07-28T07:35:21.116481Z","shell.execute_reply":"2023-07-28T07:35:21.157083Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission.head()","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.159419Z","iopub.execute_input":"2023-07-28T07:35:21.159627Z","iopub.status.idle":"2023-07-28T07:35:21.177801Z","shell.execute_reply.started":"2023-07-28T07:35:21.159600Z","shell.execute_reply":"2023-07-28T07:35:21.177082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission['label'] = prediction","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.178891Z","iopub.execute_input":"2023-07-28T07:35:21.179824Z","iopub.status.idle":"2023-07-28T07:35:21.187089Z","shell.execute_reply.started":"2023-07-28T07:35:21.179788Z","shell.execute_reply":"2023-07-28T07:35:21.186178Z"},"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":"2023-07-28T07:35:21.188648Z","iopub.execute_input":"2023-07-28T07:35:21.188908Z","iopub.status.idle":"2023-07-28T07:35:21.205023Z","shell.execute_reply.started":"2023-07-28T07:35:21.188873Z","shell.execute_reply":"2023-07-28T07:35:21.204314Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission.head()","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.206753Z","iopub.execute_input":"2023-07-28T07:35:21.206974Z","iopub.status.idle":"2023-07-28T07:35:21.220903Z","shell.execute_reply.started":"2023-07-28T07:35:21.206947Z","shell.execute_reply":"2023-07-28T07:35:21.220099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission['label'] = my_submission['label'].round(1)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.223064Z","iopub.execute_input":"2023-07-28T07:35:21.223557Z","iopub.status.idle":"2023-07-28T07:35:21.229489Z","shell.execute_reply.started":"2023-07-28T07:35:21.223515Z","shell.execute_reply":"2023-07-28T07:35:21.228790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"my_submission.to_csv('my_submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T07:35:21.230747Z","iopub.execute_input":"2023-07-28T07:35:21.231013Z","iopub.status.idle":"2023-07-28T07:35:21.262523Z","shell.execute_reply.started":"2023-07-28T07:35:21.230977Z","shell.execute_reply":"2023-07-28T07:35:21.261830Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}