<jupyter_start><jupyter_text>CSEN1022:Assignment 2Winter 2021    Please don't forget to fill in this data **Member 1**Name: <NAME>GUC-ID: 43-15747Elective Tutorial No.: T07**Member 2**Name:<NAME>GUC-ID:43-16620Elective Tutorial No.:T03   Imports (Don't Edit)<jupyter_code># ONLY USE THESE IMPORTS.
# PLEASE DON'T EDIT THIS CELL.
import numpy as np
import matplotlib.pyplot as plt
import cv2
%matplotlib inline
confusion_matrices_nb = []
confusion_matrices_gm = []<jupyter_output><empty_output><jupyter_text>Read Data<jupyter_code># X_train, X_test<jupyter_output><empty_output><jupyter_text>Construct Naive Bayes classifier for each of the 3 classes. Test each classifier on all images in X_Test.  Construct Confusion Matrix.<jupyter_code>#confusion_matrices_nb += [confusion_matrix]<jupyter_output><empty_output><jupyter_text>Construct Gaussian Generative Model classifier for each of the 3 classes. Test each classifier on all images in X_Test.  Construct Confusion Matrix.<jupyter_code>#confusion_matrices_gm += [confusion_matrix]<jupyter_output><empty_output><jupyter_text>Repeat previous two confusion matrices for image sizes 16,8,4. Return confusion_matrices (array containing 8 matrices, 4 for naive bayes, 4 for gaussian generative model).  confusion_matrices_nb = [confusion_matrix_nb_32, confusion_matrix_nb_16, confusion_matrix_nb_8, confusion_matrix_nb_4]. confusion_matrices_gm = [confusion_matrix_gm_32, confusion_matrix_gm_16, confusion_matrix_gm_8, confusion_matrix_gm_4].<jupyter_code>#confusion_matrices = confusion_matrices_nb + confusion_matrices_gm<jupyter_output><empty_output><jupyter_text>The below 2 cells will only work if you return confusion_matrices (previous cell) with all 8 matrices in it. Please don't edit the below cells. Please run them and save the notebook before uploading so the script can check the saved image. Please don't change the order of the matrices.<jupyter_code>dims = [32,16,8,4,32,16,8,4]
fig, axs = plt.subplots(2, 4,figsize=(20,10))
fig.suptitle("Confusion Matrix for each Scale",fontsize=30)
for pi in range(0,axs.shape[0]):
    for pj in range(0,axs.shape[1]):
        index = np.round(pi*4+pj)
        cm = confusion_matrices[index]
        axs[pi,pj].matshow(cm,cmap="Blues")
        axs[pi,pj].set_title("For d="+str(dims[index])+" ,acc="+str(np.round(np.diag(cm).sum()/3000,3)),fontsize=20)
        for i in range(0,cm.shape[0]):
            for j in range(0,cm.shape[1]):
                axs[pi,pj].set_xticks([])
                axs[pi,pj].set_yticks([])
                axs[pi,pj].annotate(cm[i,j],(j,i))
plt.figure(figsize=(20,10))
plt.plot(dims[:4],[np.diag(cm).sum()/3000 for cm in confusion_matrices_nb],color='orange')
plt.plot(dims[:4],[np.diag(cm).sum()/3000 for cm in confusion_matrices_gm],color='blue')
plt.xlabel('Scale')
plt.ylabel('Accuracy')
plt.title('NB VS GM')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11977715877437325, 'fraction_numerical': 0.03586350974930362, 'mean_word_length': 6.041666666666667, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '344849', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1003, 'n_words': 231, 'path': '.ipynb_checkpoints/Assignment_2-checkpoint.ipynb', 'repo_name': 'NourGhazal/Naive-bayse-Gaussian-generative-model', 'size': '2907'}