{"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\n#import numpy as np # linear algebra\n#import 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\n#import os\n#for 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-02-23T22:27:13.120875Z","iopub.execute_input":"2022-02-23T22:27:13.12121Z","iopub.status.idle":"2022-02-23T22:27:13.125481Z","shell.execute_reply.started":"2022-02-23T22:27:13.121172Z","shell.execute_reply":"2022-02-23T22:27:13.124767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport pandas as pd\nimport numpy as np\nimport zipfile\nimport random\nimport shutil\nimport tensorflow as tf\nfrom tensorflow.keras.optimizers import RMSprop\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom shutil import copyfile\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:40:13.543470Z","iopub.execute_input":"2022-02-24T09:40:13.544301Z","iopub.status.idle":"2022-02-24T09:40:13.552092Z","shell.execute_reply.started":"2022-02-24T09:40:13.544260Z","shell.execute_reply":"2022-02-24T09:40:13.551384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!wget --no-check-certificate \\\n    https://storage.googleapis.com/mledu-datasets/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5 \\\n    -O /tmp/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:40:17.395591Z","iopub.execute_input":"2022-02-24T09:40:17.396202Z","iopub.status.idle":"2022-02-24T09:40:18.741793Z","shell.execute_reply.started":"2022-02-24T09:40:17.396163Z","shell.execute_reply":"2022-02-24T09:40:18.740959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.applications.inception_v3 import InceptionV3\nfrom tensorflow.keras import layers\n\n# Set the weights file you downloaded into a variable\nlocal_weights_file = '/tmp/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5'\n\n# Initialize the base model.\n# Set the input shape and remove the dense layers.\npre_trained_model = InceptionV3(input_shape = (150, 150, 3), \n                                include_top = False, \n                                weights = None)\n\n# Load the pre-trained weights you downloaded.\npre_trained_model.load_weights(local_weights_file)\n\n# Freeze the weights of the layers.\nfor layer in pre_trained_model.layers:\n  layer.trainable = False","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:40:23.012979Z","iopub.execute_input":"2022-02-24T09:40:23.013256Z","iopub.status.idle":"2022-02-24T09:40:27.259275Z","shell.execute_reply.started":"2022-02-24T09:40:23.013227Z","shell.execute_reply":"2022-02-24T09:40:27.258542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pre_trained_model.summary()","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:40:33.124012Z","iopub.execute_input":"2022-02-24T09:40:33.124273Z","iopub.status.idle":"2022-02-24T09:40:33.260907Z","shell.execute_reply.started":"2022-02-24T09:40:33.124243Z","shell.execute_reply":"2022-02-24T09:40:33.258295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Choose `mixed_7` as the last layer of your base model\nlast_layer = pre_trained_model.get_layer('mixed7')\nprint('last layer output shape: ', last_layer.output_shape)\nlast_output = last_layer.output","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:40:45.844902Z","iopub.execute_input":"2022-02-24T09:40:45.845162Z","iopub.status.idle":"2022-02-24T09:40:45.850999Z","shell.execute_reply.started":"2022-02-24T09:40:45.845134Z","shell.execute_reply":"2022-02-24T09:40:45.850266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.optimizers import RMSprop\nfrom tensorflow.keras import Model\n\n# Flatten the output layer to 1 dimension\nx = layers.Flatten()(last_output)\n# Add a fully connected layer with 1,024 hidden units and ReLU activation\nx = layers.Dense(1024, activation='relu')(x)\n# Add a dropout rate of 0.2\nx = layers.Dropout(0.2)(x)                  \n# Add a final sigmoid layer for classification\nx = layers.Dense  (1, activation='sigmoid')(x)           \n\n# Append the dense network to the base model\nmodel = Model(pre_trained_model.input, x) \n\n# Print the model summary. See your dense network connected at the end.\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:40:50.811745Z","iopub.execute_input":"2022-02-24T09:40:50.814440Z","iopub.status.idle":"2022-02-24T09:40:50.951305Z","shell.execute_reply.started":"2022-02-24T09:40:50.814404Z","shell.execute_reply":"2022-02-24T09:40:50.950658Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Set the training parameters\nmodel.compile(optimizer = RMSprop(learning_rate=0.0001), \n              loss = 'binary_crossentropy', \n              metrics = ['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:41:19.466735Z","iopub.execute_input":"2022-02-24T09:41:19.466998Z","iopub.status.idle":"2022-02-24T09:41:19.485831Z","shell.execute_reply.started":"2022-02-24T09:41:19.466971Z","shell.execute_reply":"2022-02-24T09:41:19.485051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#deleting files to start over\n#if os.path.exists('/kaggle/working/train'):\n  # shutil.rmtree('/kaggle/working/train')\n#if os.path.exists('/kaggle/working/test1'):\n   #shutil.rmtree('/kaggle/working/test1')","metadata":{"execution":{"iopub.status.busy":"2022-02-23T22:27:24.346014Z","iopub.execute_input":"2022-02-23T22:27:24.346252Z","iopub.status.idle":"2022-02-23T22:27:24.350316Z","shell.execute_reply.started":"2022-02-23T22:27:24.346219Z","shell.execute_reply":"2022-02-23T22:27:24.34945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#import os\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n  #  for filename in filenames:\n       # print(os.path.join(dirname, filename))\n","metadata":{"execution":{"iopub.status.busy":"2022-02-23T22:27:24.351876Z","iopub.execute_input":"2022-02-23T22:27:24.352121Z","iopub.status.idle":"2022-02-23T22:27:24.357866Z","shell.execute_reply.started":"2022-02-23T22:27:24.352087Z","shell.execute_reply":"2022-02-23T22:27:24.356987Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"local_zip = '/kaggle/input/dogs-vs-cats-redux-kernels-edition/train.zip'\nzip_ref   = zipfile.ZipFile(local_zip, 'r')\nzip_ref.extractall('/kaggle/working')\nzip_ref.close()","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:41:49.867086Z","iopub.execute_input":"2022-02-24T09:41:49.867539Z","iopub.status.idle":"2022-02-24T09:42:02.925069Z","shell.execute_reply.started":"2022-02-24T09:41:49.867474Z","shell.execute_reply":"2022-02-24T09:42:02.924293Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"local_zip ='/kaggle/input/dogs-vs-cats-redux-kernels-edition/test.zip'\nzip_ref   = zipfile.ZipFile(local_zip, 'r')\nzip_ref.extractall('/kaggle/working')\nzip_ref.close()","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:42:21.580538Z","iopub.execute_input":"2022-02-24T09:42:21.581172Z","iopub.status.idle":"2022-02-24T09:42:28.470976Z","shell.execute_reply.started":"2022-02-24T09:42:21.581121Z","shell.execute_reply":"2022-02-24T09:42:28.470217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Counting the images OF CATS / DOGS","metadata":{}},{"cell_type":"code","source":"filenames = os.listdir('/kaggle/working/train')\ncategories = []\nfor filename in filenames:\n    category = filename.split('.')[0]\n    if category == 'dog':\n        categories.append(str(1))\n    else:\n        categories.append(str(0))\n\ndf = pd.DataFrame({\n    'filename': filenames,\n    'category': categories\n})\n\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:42:45.562052Z","iopub.execute_input":"2022-02-24T09:42:45.562311Z","iopub.status.idle":"2022-02-24T09:42:45.615477Z","shell.execute_reply.started":"2022-02-24T09:42:45.562280Z","shell.execute_reply":"2022-02-24T09:42:45.614699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"category\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:42:53.368061Z","iopub.execute_input":"2022-02-24T09:42:53.368314Z","iopub.status.idle":"2022-02-24T09:42:53.383334Z","shell.execute_reply.started":"2022-02-24T09:42:53.368284Z","shell.execute_reply":"2022-02-24T09:42:53.382643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### The categories are equally divided into two proportions i.e. there are 12500 pictures of each category. (50%)","metadata":{}},{"cell_type":"code","source":"# # Counting the images FOR TRAINING / TESTING","metadata":{"execution":{"iopub.status.busy":"2022-02-23T22:27:42.529537Z","iopub.execute_input":"2022-02-23T22:27:42.530332Z","iopub.status.idle":"2022-02-23T22:27:42.534122Z","shell.execute_reply.started":"2022-02-23T22:27:42.530295Z","shell.execute_reply":"2022-02-23T22:27:42.533383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"source_path = '/kaggle/working' \n\nsource_path_train = os.path.join(source_path, 'train')\nsource_path_test = os.path.join(source_path, 'test')\n\n\n# os.listdir returns a list containing all files under the given path\nprint(f\"There are {len(os.listdir(source_path_train))} images for training.\")\nprint(f\"There are {len(os.listdir(source_path_test))} images for testing.\")","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:43:02.665116Z","iopub.execute_input":"2022-02-24T09:43:02.665892Z","iopub.status.idle":"2022-02-24T09:43:02.693874Z","shell.execute_reply.started":"2022-02-24T09:43:02.665835Z","shell.execute_reply":"2022-02-24T09:43:02.693072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Creating subdirectories for cats and dogs. These will be empty!!  IN A NEW DIRECTORY 'cats-vs-dogs'","metadata":{}},{"cell_type":"code","source":"# Define root directory\nroot_dir = '/kaggle/working/cats-v-dogs' #this is new folder\n\n# Empty directory to prevent FileExistsError is the function is run several times\nif os.path.exists(root_dir):\n    shutil.rmtree(root_dir)\n\n      \nos.makedirs(root_dir + '/training')\nos.makedirs(root_dir + '/testing')\nos.makedirs(root_dir + '/training/cats')\nos.makedirs(root_dir + '/training/dogs')\nos.makedirs(root_dir + '/testing/cats')\nos.makedirs(root_dir + '/testing/dogs')\n","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:43:21.349456Z","iopub.execute_input":"2022-02-24T09:43:21.349740Z","iopub.status.idle":"2022-02-24T09:43:21.356327Z","shell.execute_reply.started":"2022-02-24T09:43:21.349709Z","shell.execute_reply":"2022-02-24T09:43:21.355647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#cheking\nfor rootdir, dirs, files in os.walk(root_dir):\n    for subdir in dirs:\n        print(os.path.join(rootdir, subdir))","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:43:27.025204Z","iopub.execute_input":"2022-02-24T09:43:27.025998Z","iopub.status.idle":"2022-02-24T09:43:27.033334Z","shell.execute_reply.started":"2022-02-24T09:43:27.025951Z","shell.execute_reply":"2022-02-24T09:43:27.032553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Copy the images from the directories train/test1 into 'cats-vs-dogs' which is EMPTY.","metadata":{}},{"cell_type":"code","source":"# split_data\ndef split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE):\n\n    files = []\n    for filename in os.listdir(SOURCE):\n      file = SOURCE + filename\n      if os.path.getsize(file) > 0:\n            files.append(filename)\n      else:\n            print(filename + \" is zero length, so ignoring.\")\n\n    training_length = int(len(files) * SPLIT_SIZE)\n    testing_length = int(len(files) - training_length)\n    shuffled_set = random.sample(files, len(files))\n    training_set = shuffled_set[0:training_length]\n    testing_set = shuffled_set[-testing_length:]\n\n    for filename in training_set:\n        this_file = SOURCE + filename\n        destination = TRAINING + filename\n        copyfile(this_file, destination)\n\n    for filename in testing_set:\n        this_file = SOURCE + filename\n        destination = TESTING + filename\n        copyfile(this_file, destination)\n    pass\n\n","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:43:34.556900Z","iopub.execute_input":"2022-02-24T09:43:34.557156Z","iopub.status.idle":"2022-02-24T09:43:34.567895Z","shell.execute_reply.started":"2022-02-24T09:43:34.557129Z","shell.execute_reply":"2022-02-24T09:43:34.566952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define paths\nTRAINING_SOURCE_DIR = \"/kaggle/working/train/\"\nTRAINING_CATS_DIR = \"/kaggle/working/cats-v-dogs/training/cats/\"\nTESTING_CATS_DIR = \"/kaggle/working/cats-v-dogs/testing/cats/\"\n\nTEST_SOURCE_DIR = \"/kaggle/working/test/\"\nTRAINING_DOGS_DIR = \"/kaggle/working/cats-v-dogs/training/dogs/\"\nTESTING_DOGS_DIR = \"/kaggle/working/cats-v-dogs/testing/dogs/\"\n\nTRAINING_DIR = \"/kaggle/working/cats-v-dogs/training/\"\nTESTING_DIR = \"/kaggle/working/cats-v-dogs/testing/\"\n\n# Empty directories in case you run this cell multiple times\nif len(os.listdir(TRAINING_CATS_DIR)) > 0:\n    for file in os.scandir(TRAINING_CATS_DIR):\n        os.remove(file.path)\nif len(os.listdir(TRAINING_DOGS_DIR)) > 0:\n    for file in os.scandir(TRAINING_DOGS_DIR):\n        os.remove(file.path)\nif len(os.listdir(TESTING_CATS_DIR)) > 0:\n    for file in os.scandir(TESTING_CATS_DIR):\n        os.remove(file.path)\nif len(os.listdir(TESTING_DOGS_DIR)) > 0:\n    for file in os.scandir(TESTING_DOGS_DIR):\n        os.remove(file.path)\n\n# Define proportion of images for cats/dogs AS SHOWN BEFORE\nsplit_size = .5\n\n# Run the function\n# NOTE: Messages about zero length images should be printed out\nsplit_data(TRAINING_SOURCE_DIR, TRAINING_CATS_DIR, TRAINING_DOGS_DIR, split_size)\nsplit_data(TEST_SOURCE_DIR, TESTING_CATS_DIR, TESTING_DOGS_DIR, split_size)\n\n# Check that the number of images matches the expected output\nprint(f\"\\n\\nThere are {len(os.listdir(TRAINING_CATS_DIR))} images of cats for training\")\nprint(f\"There are {len(os.listdir(TRAINING_DOGS_DIR))} images of dogs for training\")\nprint(f\"There are {len(os.listdir(TESTING_CATS_DIR))} images of cats for testing\")\nprint(f\"There are {len(os.listdir(TESTING_DOGS_DIR))} images of dogs for testing\")","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:43:41.462387Z","iopub.execute_input":"2022-02-24T09:43:41.463173Z","iopub.status.idle":"2022-02-24T09:43:45.139451Z","shell.execute_reply.started":"2022-02-24T09:43:41.463126Z","shell.execute_reply":"2022-02-24T09:43:45.138722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_datagen = ImageDataGenerator(rescale=1/255,\n                                     rotation_range=40,\n                                     width_shift_range=0.2,\n                                     height_shift_range=0.2,\n                                     shear_range=0.2,\n                                     zoom_range=0.2,\n                                     horizontal_flip=True,\n                                     fill_mode='nearest')\n\n#train_datagen = ImageDataGenerator(rescale=1/255)\n                            \n# Pass in the appropriate arguments to the flow_from_directory method\ntrain_generator = train_datagen.flow_from_directory(directory=TRAINING_DIR,\n                                                      batch_size=100,\n                                                      class_mode='binary',\n                                                      target_size=(150, 150))\n\n # Instantiate the ImageDataGenerator class (don't forget to set the rescale argument)\nvalidation_datagen =  ImageDataGenerator(rescale=1/255)\n    \n  # Pass in the appropriate arguments to the flow_from_directory method\nvalidation_generator = validation_datagen.flow_from_directory(directory=TESTING_DIR,\n                                                                batch_size=100,\n                                                               class_mode='binary',\n                                                              #classes=('dogs','cats'),\n                                                                target_size=(150, 150))\n","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:44:04.445327Z","iopub.execute_input":"2022-02-24T09:44:04.445609Z","iopub.status.idle":"2022-02-24T09:44:05.457933Z","shell.execute_reply.started":"2022-02-24T09:44:04.445577Z","shell.execute_reply":"2022-02-24T09:44:05.457193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class myCallback(tf.keras.callbacks.Callback):\n      def on_epoch_end(self, epoch, logs={}):\n        if(logs.get('accuracy')>0.9000):\n              print(\"\\nReached 90.00% accuracy so cancelling training!\")\n        self.model.stop_training = True\n        \n#Instantiate class\ncallbacks = myCallback()","metadata":{"execution":{"iopub.status.busy":"2022-02-23T22:27:48.074173Z","iopub.execute_input":"2022-02-23T22:27:48.074424Z","iopub.status.idle":"2022-02-23T22:27:48.081119Z","shell.execute_reply.started":"2022-02-23T22:27:48.07439Z","shell.execute_reply":"2022-02-23T22:27:48.080208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Train the model\nhistory = model.fit(\n      train_generator,\n      epochs=10,\n      validation_data=validation_generator)\n     # callbacks=callbacks)\n     # verbose=2)","metadata":{"execution":{"iopub.status.busy":"2022-02-24T09:47:06.512555Z","iopub.execute_input":"2022-02-24T09:47:06.513243Z","iopub.status.idle":"2022-02-24T10:20:58.580728Z","shell.execute_reply.started":"2022-02-24T09:47:06.513205Z","shell.execute_reply":"2022-02-24T10:20:58.579810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#-----------------------------------------------------------\n# Retrieve a list of list results on training and test data\n# sets for each training epoch\n#-----------------------------------------------------------\naccuracy=history.history['accuracy']\nval_accuracy=history.history['val_accuracy']\nloss=history.history['loss']\nval_loss=history.history['val_loss']\n\nepochs=range(len(accuracy)) # Get number of epochs\n\n#------------------------------------------------\n# Plot training and validation accuracy per epoch\n#------------------------------------------------\nplt.plot(epochs, accuracy, 'r', \"Training Accuracy\")\nplt.plot(epochs, val_accuracy, 'b', \"Validation Accuracy\")\nplt.title('Training and validation accuracy')\nplt.show()\nprint(\"\")\n\n#------------------------------------------------\n# Plot training and validation loss per epoch\n#------------------------------------------------\nplt.plot(epochs, loss, 'r', \"Training Loss\")\nplt.plot(epochs, val_loss, 'b', \"Validation Loss\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-24T10:23:11.111578Z","iopub.execute_input":"2022-02-24T10:23:11.112164Z","iopub.status.idle":"2022-02-24T10:23:11.398193Z","shell.execute_reply.started":"2022-02-24T10:23:11.112124Z","shell.execute_reply":"2022-02-24T10:23:11.397280Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.save_weights('model_catsvsdogs.h5')\nmodel.save('model_catsvsdogs.h5')","metadata":{"execution":{"iopub.status.busy":"2022-02-24T10:23:18.252482Z","iopub.execute_input":"2022-02-24T10:23:18.253047Z","iopub.status.idle":"2022-02-24T10:23:20.374693Z","shell.execute_reply.started":"2022-02-24T10:23:18.253003Z","shell.execute_reply":"2022-02-24T10:23:20.373776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Make categorical prediction:","metadata":{}},{"cell_type":"code","source":"validation_generator.reset()\npred= model.predict_generator(validation_generator, verbose=1)\n\npredicted_class_indices=[1 if x >= 0.5 else 0 for x in pred]\n\nlabels=(validation_generator.class_indices)\nlabels2=dict((v,k) for k,v in labels.items())\npredictions=[labels2[k] for k in predicted_class_indices]\n\nprint(predicted_class_indices)\nprint(labels)\nprint(predictions)","metadata":{"execution":{"iopub.status.busy":"2022-02-24T10:23:28.222920Z","iopub.execute_input":"2022-02-24T10:23:28.223448Z","iopub.status.idle":"2022-02-24T10:24:00.605087Z","shell.execute_reply.started":"2022-02-24T10:23:28.223411Z","shell.execute_reply":"2022-02-24T10:24:00.604323Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Generate .csv for submission","metadata":{}},{"cell_type":"code","source":"counter = range(1, len(predictions) + 1)\nsolution = pd.DataFrame({\"id\": counter, \"label\":predicted_class_indices})\nsolution.to_csv(\"dogsVScats.csv\", index = False)\n","metadata":{"execution":{"iopub.status.busy":"2022-02-24T10:24:08.646268Z","iopub.execute_input":"2022-02-24T10:24:08.646828Z","iopub.status.idle":"2022-02-24T10:24:08.678685Z","shell.execute_reply.started":"2022-02-24T10:24:08.646791Z","shell.execute_reply":"2022-02-24T10:24:08.678028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}}]}