{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":28755,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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)\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\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\n\n# Use the kagglehub client library to attach Kaggle resources like competitions, datasets, and models to your session\n# Learn more about kagglehub: https://github.com/Kaggle/kagglehub/blob/main/README.md\n\nimport kagglehub\n# kagglehub.dataset_download('<owner>/<dataset-slug>')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:23.630197Z","iopub.execute_input":"2026-08-31T09:54:23.630705Z","iopub.status.idle":"2026-08-31T09:54:34.649959Z","shell.execute_reply.started":"2026-08-31T09:54:23.630671Z","shell.execute_reply":"2026-08-31T09:54:34.649040Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nimport tensorflow as tf\n\nfrom tensorflow.keras import layers, models\nfrom tensorflow.keras.callbacks import EarlyStopping\nfrom sklearn.model_selection import train_test_split","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.651534Z","iopub.execute_input":"2026-08-31T09:54:34.652318Z","iopub.status.idle":"2026-08-31T09:54:34.656244Z","shell.execute_reply.started":"2026-08-31T09:54:34.652292Z","shell.execute_reply":"2026-08-31T09:54:34.655615Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\n\nfor root, dirs, files in os.walk(\"/kaggle/input\"):\n    if \"labels.csv\" in files and \"train\" in dirs and \"test\" in dirs:\n        DATASET_PATH = root\n        break\n\nprint(\"Dataset path:\", DATASET_PATH)\n\nTRAIN_DIR = os.path.join(DATASET_PATH, \"train\")\nTEST_DIR = os.path.join(DATASET_PATH, \"test\")\nLABELS_PATH = os.path.join(DATASET_PATH, \"labels.csv\")\n\nlabels_df = pd.read_csv(LABELS_PATH)\n\nprint(labels_df.head())\nprint(labels_df.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.657069Z","iopub.execute_input":"2026-08-31T09:54:34.657613Z","iopub.status.idle":"2026-08-31T09:54:34.689802Z","shell.execute_reply.started":"2026-08-31T09:54:34.657581Z","shell.execute_reply":"2026-08-31T09:54:34.689207Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Load labels.csv","metadata":{}},{"cell_type":"code","source":"DATASET_PATH = \"/kaggle/input/competitions/dog-breed-identification\"\n\nTRAIN_DIR = os.path.join(DATASET_PATH, \"train\")\nTEST_DIR = os.path.join(DATASET_PATH, \"test\")\nLABELS_PATH = os.path.join(DATASET_PATH, \"labels.csv\")\n\nlabels_df = pd.read_csv(LABELS_PATH)\n\nprint(labels_df.head())\nprint(labels_df.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.691252Z","iopub.execute_input":"2026-08-31T09:54:34.691613Z","iopub.status.idle":"2026-08-31T09:54:34.709853Z","shell.execute_reply.started":"2026-08-31T09:54:34.691580Z","shell.execute_reply":"2026-08-31T09:54:34.709213Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Create image paths","metadata":{}},{"cell_type":"code","source":"labels_df[\"filename\"] = labels_df[\"id\"] + \".jpg\"\n\nlabels_df[\"filepath\"] = labels_df[\"filename\"].apply(\n    lambda x: os.path.join(TRAIN_DIR, x)\n)\n\nprint(labels_df.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.710628Z","iopub.execute_input":"2026-08-31T09:54:34.710884Z","iopub.status.idle":"2026-08-31T09:54:34.729501Z","shell.execute_reply.started":"2026-08-31T09:54:34.710860Z","shell.execute_reply":"2026-08-31T09:54:34.728871Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Encode the 120 breeds","metadata":{}},{"cell_type":"code","source":"breeds = sorted(labels_df[\"breed\"].unique())\n\nbreed_to_index = {\n    breed: index\n    for index, breed in enumerate(breeds)\n}\n\nindex_to_breed = {\n    index: breed\n    for breed, index in breed_to_index.items()\n}\n\nlabels_df[\"label\"] = labels_df[\"breed\"].map(breed_to_index)\n\nNUM_CLASSES = len(breeds)\n\nprint(\"Number of breeds:\", NUM_CLASSES)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.730614Z","iopub.execute_input":"2026-08-31T09:54:34.731006Z","iopub.status.idle":"2026-08-31T09:54:34.744393Z","shell.execute_reply.started":"2026-08-31T09:54:34.730982Z","shell.execute_reply":"2026-08-31T09:54:34.743572Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Train-validation split","metadata":{}},{"cell_type":"code","source":"train_df, val_df = train_test_split(\n    labels_df,\n    test_size=0.2,\n    random_state=42,\n    stratify=labels_df[\"label\"]\n)\n\nprint(\"Training images:\", len(train_df))\nprint(\"Validation images:\", len(val_df))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.745514Z","iopub.execute_input":"2026-08-31T09:54:34.745965Z","iopub.status.idle":"2026-08-31T09:54:34.765605Z","shell.execute_reply.started":"2026-08-31T09:54:34.745941Z","shell.execute_reply":"2026-08-31T09:54:34.764735Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Create TensorFlow datasets","metadata":{}},{"cell_type":"code","source":"IMG_SIZE = (128, 128)\nBATCH_SIZE = 32\nAUTOTUNE = tf.data.AUTOTUNE","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.766540Z","iopub.execute_input":"2026-08-31T09:54:34.766833Z","iopub.status.idle":"2026-08-31T09:54:34.771187Z","shell.execute_reply.started":"2026-08-31T09:54:34.766812Z","shell.execute_reply":"2026-08-31T09:54:34.770663Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Create a function to load images:","metadata":{}},{"cell_type":"code","source":"def load_image(filepath, label):\n    image = tf.io.read_file(filepath)\n\n    image = tf.image.decode_jpeg(\n        image,\n        channels=3\n    )\n\n    image = tf.image.resize(\n        image,\n        IMG_SIZE\n    )\n\n    image = tf.cast(image, tf.float32) / 255.0\n\n    return image, label","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.772402Z","iopub.execute_input":"2026-08-31T09:54:34.772836Z","iopub.status.idle":"2026-08-31T09:54:34.782489Z","shell.execute_reply.started":"2026-08-31T09:54:34.772811Z","shell.execute_reply":"2026-08-31T09:54:34.781865Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Now create the datasets:","metadata":{}},{"cell_type":"code","source":"train_ds = tf.data.Dataset.from_tensor_slices(\n    (\n        train_df[\"filepath\"].values,\n        train_df[\"label\"].values\n    )\n)\n\nval_ds = tf.data.Dataset.from_tensor_slices(\n    (\n        val_df[\"filepath\"].values,\n        val_df[\"label\"].values\n    )\n)\n\ntrain_ds = (\n    train_ds\n    .shuffle(len(train_df))\n    .map(load_image, num_parallel_calls=AUTOTUNE)\n    .batch(BATCH_SIZE)\n    .prefetch(AUTOTUNE)\n)\n\nval_ds = (\n    val_ds\n    .map(load_image, num_parallel_calls=AUTOTUNE)\n    .batch(BATCH_SIZE)\n    .prefetch(AUTOTUNE)\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.784780Z","iopub.execute_input":"2026-08-31T09:54:34.785116Z","iopub.status.idle":"2026-08-31T09:54:34.861593Z","shell.execute_reply.started":"2026-08-31T09:54:34.785094Z","shell.execute_reply":"2026-08-31T09:54:34.860830Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_augmentation = tf.keras.Sequential([\n    tf.keras.layers.RandomFlip(\"horizontal\")\n])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.862621Z","iopub.execute_input":"2026-08-31T09:54:34.862899Z","iopub.status.idle":"2026-08-31T09:54:34.870211Z","shell.execute_reply.started":"2026-08-31T09:54:34.862868Z","shell.execute_reply":"2026-08-31T09:54:34.869539Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"CNN Mode","metadata":{}},{"cell_type":"code","source":"model = tf.keras.Sequential([\n\n    tf.keras.layers.Input(shape=(128, 128, 3)),\n\n    # Data augmentation\n    data_augmentation,\n\n    # Block 1\n    tf.keras.layers.Conv2D(32, 3, padding=\"same\", activation=\"relu\"),\n    tf.keras.layers.BatchNormalization(),\n    tf.keras.layers.MaxPooling2D(2),\n\n    # Block 2\n    tf.keras.layers.Conv2D(64, 3, padding=\"same\", activation=\"relu\"),\n    tf.keras.layers.BatchNormalization(),\n    tf.keras.layers.MaxPooling2D(2),\n\n    # Block 3\n    tf.keras.layers.Conv2D(128, 3, padding=\"same\", activation=\"relu\"),\n    tf.keras.layers.BatchNormalization(),\n    tf.keras.layers.MaxPooling2D(2),\n\n    # Block 4\n    tf.keras.layers.Conv2D(256, 3, padding=\"same\", activation=\"relu\"),\n    tf.keras.layers.BatchNormalization(),\n    tf.keras.layers.MaxPooling2D(2),\n\n    # Classification\n    tf.keras.layers.GlobalAveragePooling2D(),\n\n    tf.keras.layers.Dense(256, activation=\"relu\"),\n    tf.keras.layers.Dropout(0.5),\n\n    tf.keras.layers.Dense(\n        NUM_CLASSES,\n        activation=\"softmax\"\n    )\n])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.870984Z","iopub.execute_input":"2026-08-31T09:54:34.871163Z","iopub.status.idle":"2026-08-31T09:54:34.954342Z","shell.execute_reply.started":"2026-08-31T09:54:34.871144Z","shell.execute_reply":"2026-08-31T09:54:34.953537Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Check the architecture:","metadata":{}},{"cell_type":"code","source":"model.summary()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.955279Z","iopub.execute_input":"2026-08-31T09:54:34.955575Z","iopub.status.idle":"2026-08-31T09:54:34.980572Z","shell.execute_reply.started":"2026-08-31T09:54:34.955525Z","shell.execute_reply":"2026-08-31T09:54:34.980022Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Compile the model","metadata":{}},{"cell_type":"code","source":"model.compile(\n    optimizer=tf.keras.optimizers.Adam(\n        learning_rate=0.0001\n    ),\n    loss=\"sparse_categorical_crossentropy\",\n    metrics=[\"accuracy\"]\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.981469Z","iopub.execute_input":"2026-08-31T09:54:34.981826Z","iopub.status.idle":"2026-08-31T09:54:34.989398Z","shell.execute_reply.started":"2026-08-31T09:54:34.981802Z","shell.execute_reply":"2026-08-31T09:54:34.988850Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Early Stopping","metadata":{}},{"cell_type":"code","source":"early_stopping = tf.keras.callbacks.EarlyStopping(\n    monitor=\"val_loss\",\n    patience=8,\n    restore_best_weights=True,\n    verbose=1\n\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:34.990306Z","iopub.execute_input":"2026-08-31T09:54:34.990597Z","iopub.status.idle":"2026-08-31T09:54:35.001185Z","shell.execute_reply.started":"2026-08-31T09:54:34.990565Z","shell.execute_reply":"2026-08-31T09:54:35.000398Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Train","metadata":{}},{"cell_type":"code","source":"history = model.fit(\n    train_ds,\n    validation_data=val_ds,\n    epochs=50,\n    callbacks=[early_stopping]\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T09:54:35.002145Z","iopub.execute_input":"2026-08-31T09:54:35.002498Z","iopub.status.idle":"2026-08-31T10:01:14.701417Z","shell.execute_reply.started":"2026-08-31T09:54:35.002467Z","shell.execute_reply":"2026-08-31T10:01:14.700746Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Evaluate","metadata":{}},{"cell_type":"code","source":"loss, accuracy = model.evaluate(val_ds)\n\nprint(\"Validation Loss:\", loss)\nprint(\"Validation Accuracy:\", accuracy)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:01:14.702388Z","iopub.execute_input":"2026-08-31T10:01:14.703423Z","iopub.status.idle":"2026-08-31T10:01:16.185954Z","shell.execute_reply.started":"2026-08-31T10:01:14.703385Z","shell.execute_reply":"2026-08-31T10:01:16.185243Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Predict a dog breed","metadata":{}},{"cell_type":"code","source":"print(\"Best validation accuracy:\",\n      max(history.history[\"val_accuracy\"]))\n\nprint(\"Best validation loss:\",\n      min(history.history[\"val_loss\"]))\n\nprint(\"Best accuracy epoch:\",\n      history.history[\"val_accuracy\"].index(\n          max(history.history[\"val_accuracy\"])\n      ) + 1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:01:16.186864Z","iopub.execute_input":"2026-08-31T10:01:16.187367Z","iopub.status.idle":"2026-08-31T10:01:16.192529Z","shell.execute_reply.started":"2026-08-31T10:01:16.187340Z","shell.execute_reply":"2026-08-31T10:01:16.191964Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def predict_breed(image_path):\n\n    image = tf.io.read_file(image_path)\n\n    image = tf.image.decode_jpeg(\n        image,\n        channels=3\n    )\n\n    image = tf.image.resize(\n        image,\n        IMG_SIZE\n    )\n\n    image = tf.cast(image, tf.float32) / 255.0\n\n    image = tf.expand_dims(\n        image,\n        axis=0\n    )\n\n    predictions = model.predict(image, verbose=0)\n\n    predicted_index = np.argmax(predictions[0])\n\n    predicted_breed = index_to_breed[predicted_index]\n\n    confidence = predictions[0][predicted_index]\n\n    return predicted_breed, confidence","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:01:16.193542Z","iopub.execute_input":"2026-08-31T10:01:16.193830Z","iopub.status.idle":"2026-08-31T10:01:16.204753Z","shell.execute_reply.started":"2026-08-31T10:01:16.193808Z","shell.execute_reply":"2026-08-31T10:01:16.204102Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"image_path = train_df.iloc[0][\"filepath\"]\n\nbreed, confidence = predict_breed(image_path)\n\nprint(\"Predicted breed:\", breed)\nprint(\"Confidence:\", confidence)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:01:16.205527Z","iopub.execute_input":"2026-08-31T10:01:16.206157Z","iopub.status.idle":"2026-08-31T10:01:16.852173Z","shell.execute_reply.started":"2026-08-31T10:01:16.206109Z","shell.execute_reply":"2026-08-31T10:01:16.851486Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"Create the test dataset","metadata":{}},{"cell_type":"markdown","source":"# ","metadata":{}},{"cell_type":"code","source":"test_files = [\n    os.path.join(TEST_DIR, filename)\n    for filename in os.listdir(TEST_DIR)\n    if filename.endswith(\".jpg\")\n]\n\nprint(\"Number of test images:\", len(test_files))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:03:30.096509Z","iopub.execute_input":"2026-08-31T10:03:30.097001Z","iopub.status.idle":"2026-08-31T10:03:30.118264Z","shell.execute_reply.started":"2026-08-31T10:03:30.096963Z","shell.execute_reply":"2026-08-31T10:03:30.117630Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def load_test_image(filepath):\n    image = tf.io.read_file(filepath)\n\n    image = tf.image.decode_jpeg(\n        image,\n        channels=3\n    )\n\n    image = tf.image.resize(\n        image,\n        IMG_SIZE\n    )\n\n    image = tf.cast(\n        image,\n        tf.float32\n    ) / 255.0\n\n    return image","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:03:32.648125Z","iopub.execute_input":"2026-08-31T10:03:32.648901Z","iopub.status.idle":"2026-08-31T10:03:32.653463Z","shell.execute_reply.started":"2026-08-31T10:03:32.648874Z","shell.execute_reply":"2026-08-31T10:03:32.652615Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_ds = tf.data.Dataset.from_tensor_slices(test_files)\n\ntest_ds = (\n    test_ds\n    .map(load_test_image, num_parallel_calls=AUTOTUNE)\n    .batch(BATCH_SIZE)\n    .prefetch(AUTOTUNE)\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:03:40.857234Z","iopub.execute_input":"2026-08-31T10:03:40.858129Z","iopub.status.idle":"2026-08-31T10:03:40.893862Z","shell.execute_reply.started":"2026-08-31T10:03:40.858089Z","shell.execute_reply":"2026-08-31T10:03:40.893252Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def load_test_image(filepath):\n\n    image = tf.io.read_file(filepath)\n\n    image = tf.image.decode_jpeg(\n        image,\n        channels=3\n    )\n\n    image = tf.image.resize(\n        image,\n        IMG_SIZE\n    )\n\n    image = tf.cast(\n        image,\n        tf.float32\n    ) / 255.0\n\n    return image","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:03:43.497885Z","iopub.execute_input":"2026-08-31T10:03:43.498767Z","iopub.status.idle":"2026-08-31T10:03:43.504308Z","shell.execute_reply.started":"2026-08-31T10:03:43.498737Z","shell.execute_reply":"2026-08-31T10:03:43.503623Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"predictions = model.predict(\n    test_ds,\n    verbose=1\n)\n\nprint(\"Prediction shape:\", predictions.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:03:48.080197Z","iopub.execute_input":"2026-08-31T10:03:48.080687Z","iopub.status.idle":"2026-08-31T10:04:05.607925Z","shell.execute_reply.started":"2026-08-31T10:03:48.080657Z","shell.execute_reply":"2026-08-31T10:04:05.607176Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(predictions[0].sum())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:04:13.162992Z","iopub.execute_input":"2026-08-31T10:04:13.163718Z","iopub.status.idle":"2026-08-31T10:04:13.168143Z","shell.execute_reply.started":"2026-08-31T10:04:13.163686Z","shell.execute_reply":"2026-08-31T10:04:13.167411Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_ids = [\n    os.path.splitext(os.path.basename(filepath))[0]\n    for filepath in test_files\n]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:04:20.560274Z","iopub.execute_input":"2026-08-31T10:04:20.560726Z","iopub.status.idle":"2026-08-31T10:04:20.574787Z","shell.execute_reply.started":"2026-08-31T10:04:20.560697Z","shell.execute_reply":"2026-08-31T10:04:20.573970Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission = pd.DataFrame(\n    predictions,\n    columns=breeds\n)\n\nsubmission.insert(\n    0,\n    \"id\",\n    test_ids\n)\n\nprint(submission.head())\nprint(submission.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:04:23.007653Z","iopub.execute_input":"2026-08-31T10:04:23.007913Z","iopub.status.idle":"2026-08-31T10:04:23.024088Z","shell.execute_reply.started":"2026-08-31T10:04:23.007891Z","shell.execute_reply":"2026-08-31T10:04:23.023121Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission.to_csv(\n    \"submission.csv\",\n    index=False\n)\n\nprint(\"submission.csv created!\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:04:36.153810Z","iopub.execute_input":"2026-08-31T10:04:36.154218Z","iopub.status.idle":"2026-08-31T10:04:37.556025Z","shell.execute_reply.started":"2026-08-31T10:04:36.154186Z","shell.execute_reply":"2026-08-31T10:04:37.555097Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls -lh submission.csv","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:04:51.017008Z","iopub.execute_input":"2026-08-31T10:04:51.017444Z","iopub.status.idle":"2026-08-31T10:04:51.225943Z","shell.execute_reply.started":"2026-08-31T10:04:51.017410Z","shell.execute_reply":"2026-08-31T10:04:51.224793Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(\"Rows:\", len(submission))\nprint(\"Columns:\", len(submission.columns))\n\nprint(\"Expected classes:\", NUM_CLASSES)\nprint(\"Actual probability columns:\", len(submission.columns) - 1)\n\nprint(\"\\nMissing values:\")\nprint(submission.isnull().sum().sum())\n\nprint(\"\\nFirst rows:\")\nprint(submission.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:04:57.610188Z","iopub.execute_input":"2026-08-31T10:04:57.610482Z","iopub.status.idle":"2026-08-31T10:04:57.633459Z","shell.execute_reply.started":"2026-08-31T10:04:57.610455Z","shell.execute_reply":"2026-08-31T10:04:57.632425Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"probability_columns = submission.columns[1:]\n\nprint(\n    submission[probability_columns]\n    .sum(axis=1)\n    .head()\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:05:02.601961Z","iopub.execute_input":"2026-08-31T10:05:02.602384Z","iopub.status.idle":"2026-08-31T10:05:02.621623Z","shell.execute_reply.started":"2026-08-31T10:05:02.602351Z","shell.execute_reply":"2026-08-31T10:05:02.620701Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\n\nimage_index = 0\n\npredicted_index = np.argmax(\n    predictions[image_index]\n)\n\npredicted_breed = breeds[predicted_index]\n\nconfidence = predictions[\n    image_index,\n    predicted_index\n]\n\nprint(\"Image:\", test_ids[image_index])\nprint(\"Predicted breed:\", predicted_breed)\nprint(\"Confidence:\", confidence)\nprint(\"Confidence %:\", confidence * 100)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-08-31T10:05:05.201007Z","iopub.execute_input":"2026-08-31T10:05:05.201688Z","iopub.status.idle":"2026-08-31T10:05:05.207647Z","shell.execute_reply.started":"2026-08-31T10:05:05.201655Z","shell.execute_reply":"2026-08-31T10:05:05.206714Z"}},"outputs":[],"execution_count":null}]}