{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":3649,"databundleVersionId":46718,"sourceType":"competition"},{"sourceId":152217357,"sourceType":"kernelVersion"}],"dockerImageVersionId":30588,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# **Importing dependencies**","metadata":{}},{"cell_type":"code","source":"import os\nimport cv2\nimport numpy as np\nimport pandas as pd\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:20.654440Z","iopub.execute_input":"2023-11-25T09:04:20.655174Z","iopub.status.idle":"2023-11-25T09:04:20.660181Z","shell.execute_reply.started":"2023-11-25T09:04:20.655141Z","shell.execute_reply":"2023-11-25T09:04:20.659159Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Image Processing","metadata":{}},{"cell_type":"markdown","source":"**Convert images to numpy arrays**\n\nDone in traing in Extracting train notebook\n\nExporting the process image of numpyarray in data from extracting-train notebook","metadata":{}},{"cell_type":"code","source":"# Load the data\nloaded_data = np.load('/kaggle/input/extracting-train/training_data.npz')\n\n# Access the NumPy array\ndata = loaded_data['data']","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:20.662512Z","iopub.execute_input":"2023-11-25T09:04:20.663603Z","iopub.status.idle":"2023-11-25T09:04:20.871157Z","shell.execute_reply.started":"2023-11-25T09:04:20.663567Z","shell.execute_reply":"2023-11-25T09:04:20.870022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Analyzing the train set**","metadata":{}},{"cell_type":"code","source":"image_count = data.shape[0]\nprint('Number of images: ', image_count)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:20.873185Z","iopub.execute_input":"2023-11-25T09:04:20.873596Z","iopub.status.idle":"2023-11-25T09:04:20.879272Z","shell.execute_reply.started":"2023-11-25T09:04:20.873562Z","shell.execute_reply":"2023-11-25T09:04:20.878215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Displaying the images**","metadata":{}},{"cell_type":"code","source":"#display an image\nimg = data[9998]\nplt.figure(figsize=(2,1))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:20.880571Z","iopub.execute_input":"2023-11-25T09:04:20.880922Z","iopub.status.idle":"2023-11-25T09:04:21.090326Z","shell.execute_reply.started":"2023-11-25T09:04:20.880883Z","shell.execute_reply":"2023-11-25T09:04:21.089327Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#display an image\nimg = data[10012]\nplt.figure(figsize=(2,1))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.093298Z","iopub.execute_input":"2023-11-25T09:04:21.093952Z","iopub.status.idle":"2023-11-25T09:04:21.302061Z","shell.execute_reply.started":"2023-11-25T09:04:21.093912Z","shell.execute_reply":"2023-11-25T09:04:21.300988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Labels Processing**","metadata":{}},{"cell_type":"code","source":"labels_df = pd.read_csv('/kaggle/input/cifar-10/trainLabels.csv')","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.303919Z","iopub.execute_input":"2023-11-25T09:04:21.304249Z","iopub.status.idle":"2023-11-25T09:04:21.328574Z","shell.execute_reply.started":"2023-11-25T09:04:21.304221Z","shell.execute_reply":"2023-11-25T09:04:21.327546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_df.shape","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.330006Z","iopub.execute_input":"2023-11-25T09:04:21.330372Z","iopub.status.idle":"2023-11-25T09:04:21.337148Z","shell.execute_reply.started":"2023-11-25T09:04:21.330341Z","shell.execute_reply":"2023-11-25T09:04:21.336063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.338394Z","iopub.execute_input":"2023-11-25T09:04:21.338779Z","iopub.status.idle":"2023-11-25T09:04:21.350519Z","shell.execute_reply.started":"2023-11-25T09:04:21.338745Z","shell.execute_reply":"2023-11-25T09:04:21.349532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_df[labels_df['id'] == 7796]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.352145Z","iopub.execute_input":"2023-11-25T09:04:21.352467Z","iopub.status.idle":"2023-11-25T09:04:21.364591Z","shell.execute_reply.started":"2023-11-25T09:04:21.352440Z","shell.execute_reply":"2023-11-25T09:04:21.363608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_df.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.365666Z","iopub.execute_input":"2023-11-25T09:04:21.365956Z","iopub.status.idle":"2023-11-25T09:04:21.378196Z","shell.execute_reply.started":"2023-11-25T09:04:21.365928Z","shell.execute_reply":"2023-11-25T09:04:21.377189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_df.tail(10)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.382779Z","iopub.execute_input":"2023-11-25T09:04:21.383207Z","iopub.status.idle":"2023-11-25T09:04:21.394897Z","shell.execute_reply.started":"2023-11-25T09:04:21.383178Z","shell.execute_reply":"2023-11-25T09:04:21.393861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Labels are marked serially by id and evenly distributed ( below )","metadata":{}},{"cell_type":"code","source":"labels_df['label'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.396286Z","iopub.execute_input":"2023-11-25T09:04:21.396624Z","iopub.status.idle":"2023-11-25T09:04:21.412986Z","shell.execute_reply.started":"2023-11-25T09:04:21.396598Z","shell.execute_reply":"2023-11-25T09:04:21.411999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_df['label']","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.414547Z","iopub.execute_input":"2023-11-25T09:04:21.414868Z","iopub.status.idle":"2023-11-25T09:04:21.424382Z","shell.execute_reply.started":"2023-11-25T09:04:21.414842Z","shell.execute_reply":"2023-11-25T09:04:21.423396Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_dictionary = {'airplane':0, 'automobile':1, 'bird':2, 'cat':3, 'deer':4, 'dog':5, 'frog':6, 'horse':7, 'ship':8, 'truck':9}\n\nlabels = [labels_dictionary[i] for i in labels_df['label']]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.425722Z","iopub.execute_input":"2023-11-25T09:04:21.426051Z","iopub.status.idle":"2023-11-25T09:04:21.445396Z","shell.execute_reply.started":"2023-11-25T09:04:21.426025Z","shell.execute_reply":"2023-11-25T09:04:21.444550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(labels[0:5])\nprint(labels[-5:])","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.446732Z","iopub.execute_input":"2023-11-25T09:04:21.447029Z","iopub.status.idle":"2023-11-25T09:04:21.459446Z","shell.execute_reply.started":"2023-11-25T09:04:21.447003Z","shell.execute_reply":"2023-11-25T09:04:21.458435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(labels)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.461261Z","iopub.execute_input":"2023-11-25T09:04:21.461854Z","iopub.status.idle":"2023-11-25T09:04:21.471356Z","shell.execute_reply.started":"2023-11-25T09:04:21.461820Z","shell.execute_reply":"2023-11-25T09:04:21.470519Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Checking labels correctness:","metadata":{}},{"cell_type":"code","source":"img = data[9998]\nplt.figure(figsize=(2,1))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.472465Z","iopub.execute_input":"2023-11-25T09:04:21.472828Z","iopub.status.idle":"2023-11-25T09:04:21.679443Z","shell.execute_reply.started":"2023-11-25T09:04:21.472796Z","shell.execute_reply":"2023-11-25T09:04:21.678472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels_df[labels_df['id'] == 9999]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.681290Z","iopub.execute_input":"2023-11-25T09:04:21.681632Z","iopub.status.idle":"2023-11-25T09:04:21.694594Z","shell.execute_reply.started":"2023-11-25T09:04:21.681601Z","shell.execute_reply":"2023-11-25T09:04:21.693298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels[9998] # automobile = 1 , and 0 base indexing in List","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.696055Z","iopub.execute_input":"2023-11-25T09:04:21.696425Z","iopub.status.idle":"2023-11-25T09:04:21.711887Z","shell.execute_reply.started":"2023-11-25T09:04:21.696381Z","shell.execute_reply":"2023-11-25T09:04:21.710737Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"id_list = list(labels_df['id'])","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.713659Z","iopub.execute_input":"2023-11-25T09:04:21.714462Z","iopub.status.idle":"2023-11-25T09:04:21.737704Z","shell.execute_reply.started":"2023-11-25T09:04:21.714415Z","shell.execute_reply":"2023-11-25T09:04:21.736169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(id_list[0:5])\nprint(id_list[-5:])","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.739393Z","iopub.execute_input":"2023-11-25T09:04:21.741020Z","iopub.status.idle":"2023-11-25T09:04:21.750036Z","shell.execute_reply.started":"2023-11-25T09:04:21.740959Z","shell.execute_reply":"2023-11-25T09:04:21.748688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data -> x , Labels -> y","metadata":{}},{"cell_type":"code","source":"type(data)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.751403Z","iopub.execute_input":"2023-11-25T09:04:21.752306Z","iopub.status.idle":"2023-11-25T09:04:21.763110Z","shell.execute_reply.started":"2023-11-25T09:04:21.752246Z","shell.execute_reply":"2023-11-25T09:04:21.761631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(data)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.764452Z","iopub.execute_input":"2023-11-25T09:04:21.765007Z","iopub.status.idle":"2023-11-25T09:04:21.772204Z","shell.execute_reply.started":"2023-11-25T09:04:21.764965Z","shell.execute_reply":"2023-11-25T09:04:21.771146Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"type(data[0])","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.773727Z","iopub.execute_input":"2023-11-25T09:04:21.774127Z","iopub.status.idle":"2023-11-25T09:04:21.782490Z","shell.execute_reply.started":"2023-11-25T09:04:21.774093Z","shell.execute_reply":"2023-11-25T09:04:21.781557Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data[0].shape","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.783719Z","iopub.execute_input":"2023-11-25T09:04:21.784020Z","iopub.status.idle":"2023-11-25T09:04:21.792838Z","shell.execute_reply.started":"2023-11-25T09:04:21.783995Z","shell.execute_reply":"2023-11-25T09:04:21.791845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# convert image list and label list to numpy arrays\n\nx = data\ny = np.array(labels)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.794614Z","iopub.execute_input":"2023-11-25T09:04:21.794957Z","iopub.status.idle":"2023-11-25T09:04:21.807394Z","shell.execute_reply.started":"2023-11-25T09:04:21.794930Z","shell.execute_reply":"2023-11-25T09:04:21.806452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"type(x)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.808533Z","iopub.execute_input":"2023-11-25T09:04:21.808896Z","iopub.status.idle":"2023-11-25T09:04:21.818297Z","shell.execute_reply.started":"2023-11-25T09:04:21.808861Z","shell.execute_reply":"2023-11-25T09:04:21.817408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(x.shape)\nprint(y.shape)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:21.819577Z","iopub.execute_input":"2023-11-25T09:04:21.819946Z","iopub.status.idle":"2023-11-25T09:04:21.828693Z","shell.execute_reply.started":"2023-11-25T09:04:21.819916Z","shell.execute_reply":"2023-11-25T09:04:21.827711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# #small data for testing while naking the model\n# x = x[:10000]\n# y = y[:10000]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:46.527037Z","iopub.execute_input":"2023-11-25T09:04:46.527437Z","iopub.status.idle":"2023-11-25T09:04:46.532238Z","shell.execute_reply.started":"2023-11-25T09:04:46.527406Z","shell.execute_reply":"2023-11-25T09:04:46.531213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x[0]","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:47.019095Z","iopub.execute_input":"2023-11-25T09:04:47.019436Z","iopub.status.idle":"2023-11-25T09:04:47.027436Z","shell.execute_reply.started":"2023-11-25T09:04:47.019411Z","shell.execute_reply":"2023-11-25T09:04:47.026424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Defining the neural network using Resnet50","metadata":{}},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow import keras","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:48.022613Z","iopub.execute_input":"2023-11-25T09:04:48.023372Z","iopub.status.idle":"2023-11-25T09:04:48.028008Z","shell.execute_reply.started":"2023-11-25T09:04:48.023339Z","shell.execute_reply":"2023-11-25T09:04:48.026896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras import Sequential, models, layers\nfrom tensorflow.keras.layers import Dense, Dropout, Flatten\nfrom tensorflow.keras.layers import BatchNormalization\nfrom tensorflow.keras.models import load_model\nfrom tensorflow.keras.models import Model\nfrom tensorflow.keras.applications.resnet50 import ResNet50\nfrom tensorflow.keras import optimizers","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:48.250069Z","iopub.execute_input":"2023-11-25T09:04:48.250891Z","iopub.status.idle":"2023-11-25T09:04:48.255978Z","shell.execute_reply.started":"2023-11-25T09:04:48.250858Z","shell.execute_reply":"2023-11-25T09:04:48.255027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Resnet: https://keras.io/api/applications/resnet/","metadata":{}},{"cell_type":"code","source":"def createModel():\n    \n    num_of_classes = 10\n    \n    convolutional_base = ResNet50(weights='imagenet', include_top=False, input_shape=(256,256,3))\n    \n    model = models.Sequential() \n    \n    model.add(layers.UpSampling2D((2,2))) # 32 * 2 = 64\n    model.add(layers.UpSampling2D((2,2))) # 64 * 2 = 128\n    model.add(layers.UpSampling2D((2,2))) # 128 * 2 = 256\n\n    model.add(convolutional_base)\n\n    model.add(layers.Flatten())  # transforms the input into a one-dimensional array (flattens it) without modifying the actual data. \n\n    model.add(layers.BatchNormalization()) #normalization\n    model.add(layers.Dense(128, activation='relu'))\n\n    model.add(layers.Dropout(0.5)) #droping or making somen neuron inactive to avoid overfitting\n\n    model.add(layers.BatchNormalization())\n    model.add(layers.Dense(num_of_classes, activation='softmax'))\n    \n    return model\n","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:48.575040Z","iopub.execute_input":"2023-11-25T09:04:48.575748Z","iopub.status.idle":"2023-11-25T09:04:48.583237Z","shell.execute_reply.started":"2023-11-25T09:04:48.575716Z","shell.execute_reply":"2023-11-25T09:04:48.582309Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Training on different different training split","metadata":{}},{"cell_type":"code","source":"# Define data percentages\ndata_percentages = [0.1, 0.2, 0.3, 0.4, 0.5]\n\n\nhistories = []\naccuracies = []\nlosses = []\nf1_scores = []\nconf_mats = []","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:48.906327Z","iopub.execute_input":"2023-11-25T09:04:48.907307Z","iopub.status.idle":"2023-11-25T09:04:48.912178Z","shell.execute_reply.started":"2023-11-25T09:04:48.907270Z","shell.execute_reply":"2023-11-25T09:04:48.911137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import f1_score\nfrom tensorflow.math import confusion_matrix","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:49.055323Z","iopub.execute_input":"2023-11-25T09:04:49.055694Z","iopub.status.idle":"2023-11-25T09:04:49.060385Z","shell.execute_reply.started":"2023-11-25T09:04:49.055665Z","shell.execute_reply":"2023-11-25T09:04:49.059323Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Loop over data percentages\nfor data_percentage in data_percentages:\n    \n    x_train, x_test, y_train, y_test = train_test_split(x, y, train_size=data_percentage, random_state=2)\n    \n    # scaling data\n    x_train_scaled = x_train/255\n    x_test_scaled = x_test/255\n    \n    # Building the model and compiling it\n    model = createModel()\n    model.compile(optimizer=optimizers.RMSprop(lr=2e-5), loss='sparse_categorical_crossentropy', metrics=['accuracy'])\n    \n    # Train the model\n    history = model.fit(x_train_scaled, y_train, validation_split=0.1, epochs= 10, batch_size=100)\n    \n    # making prediction on test data\n    y_pred = model.predict(x_test_scaled)\n    y_pred_labels = y_pred.argmax(1)\n    \n    # Evaluate the model on the test set\n    \n    split_f1_score = f1_score(y_test, y_pred_labels, average=\"macro\")\n    loss, accuracy  = model.evaluate(x_test_scaled, y_test)\n    conf_mat = confusion_matrix(y_test, y_pred_labels)\n\n    histories.append(history)\n    accuracies.append(accuracy)\n    losses.append(loss)\n    f1_scores.append(split_f1_score)\n    conf_mats.append(conf_mat)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:04:49.214430Z","iopub.execute_input":"2023-11-25T09:04:49.214840Z","iopub.status.idle":"2023-11-25T09:11:31.946253Z","shell.execute_reply.started":"2023-11-25T09:04:49.214810Z","shell.execute_reply":"2023-11-25T09:11:31.945378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Printing the evaluation","metadata":{}},{"cell_type":"code","source":"from tabulate import tabulate\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:11:31.947937Z","iopub.execute_input":"2023-11-25T09:11:31.948269Z","iopub.status.idle":"2023-11-25T09:11:32.134544Z","shell.execute_reply.started":"2023-11-25T09:11:31.948242Z","shell.execute_reply":"2023-11-25T09:11:32.133551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"table_data = []\nfor i, data_percentage in enumerate(data_percentages):\n    table_data.append([f\"{data_percentage * 100:.0f}%\", accuracies[i], losses[i], f1_scores[i]])\n\nheaders = [\"Train Data\", \"Accuracy\", \"Loss\", \"F1-Score\"]\ntable = tabulate(table_data, headers=headers, tablefmt=\"pretty\")\n\nprint(table)","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:11:32.135672Z","iopub.execute_input":"2023-11-25T09:11:32.135946Z","iopub.status.idle":"2023-11-25T09:11:32.143794Z","shell.execute_reply.started":"2023-11-25T09:11:32.135922Z","shell.execute_reply":"2023-11-25T09:11:32.142719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Printing the confusion matrix**","metadata":{}},{"cell_type":"code","source":"for i, data_percentage in enumerate(data_percentages):\n    plt.figure(figsize=(15, 7))\n    sns.heatmap(conf_mats[i], annot=True, fmt='d', cmap='Blues')\n    plt.ylabel('True Labels')\n    plt.xlabel('Predicted Labels')\n    plt.title(f'Model Trained on {data_percentage * 100:.0f}% Data')\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-25T09:11:32.145836Z","iopub.execute_input":"2023-11-25T09:11:32.146136Z","iopub.status.idle":"2023-11-25T09:11:35.184092Z","shell.execute_reply.started":"2023-11-25T09:11:32.146111Z","shell.execute_reply":"2023-11-25T09:11:35.183070Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}