CMSC_828C_Project1/KNN.py
def plot_images(a,b,x_train, y_train, y_pred):
    """
    This function plots the images in a 5x5 grid
    :param a: true class label
    :param b: predicted class label
    :param x_train: training data
    :param y_train: training data labels
    :param y_pred: prediction on the test data
    :return: None
    """
    cl_a = a
    cl_b = b
    x_aa = x_train[(y_train == cl_a) & (y_pred == cl_a)]
    x_ab = x_train[(y_train == cl_a) & (y_pred == cl_b)]
    x_ba = x_train[(y_train == cl_b) & (y_pred == cl_a)]
    x_bb = x_train[(y_train == cl_b) & (y_pred == cl_b)]
    plt.figure(figsize=(8,8))
    plt.subplot(221)
    plot_classes(x_aa[:25], images_per_row=5)
    plt.subplot(222)
    plot_classes(x_ab[:25], images_per_row=5)
    plt.subplot(223)
    plot_classes(x_ba[:25], images_per_row=5)
    plt.subplot(224)
    plot_classes(x_bb[:25], images_per_row=5)
    plt.show()

    This function plots the images in a 5x5 grid
    :param a: true class label
    :param b: predicted class label
    :param x_train: training data
    :param y_train: training data labels
    :param y_pred: prediction on the test data
    :return: None
    
This function plots the images in a 5x5 grid
This function plots the images in a 5x5 grid
def plot_images(a,b,x_train, y_train, y_pred):
    cl_a = a
    cl_b = b
    x_aa = x_train[(y_train == cl_a) & (y_pred == cl_a)]
    x_ab = x_train[(y_train == cl_a) & (y_pred == cl_b)]
    x_ba = x_train[(y_train == cl_b) & (y_pred == cl_a)]
    x_bb = x_train[(y_train == cl_b) & (y_pred == cl_b)]
    plt.figure(figsize=(8,8))
    plt.subplot(221)
    plot_classes(x_aa[:25], images_per_row=5)
    plt.subplot(222)
    plot_classes(x_ab[:25], images_per_row=5)
    plt.subplot(223)
    plot_classes(x_ba[:25], images_per_row=5)
    plt.subplot(224)
    plot_classes(x_bb[:25], images_per_row=5)
    plt.show()
def plot_images ( a , b , x_train , y_train , y_pred ) : cl_a = a cl_b = b x_aa = x_train [ ( y_train == cl_a ) & ( y_pred == cl_a ) ] x_ab = x_train [ ( y_train == cl_a ) & ( y_pred == cl_b ) ] x_ba = x_train [ ( y_train == cl_b ) & ( y_pred == cl_a ) ] x_bb = x_train [ ( y_train == cl_b ) & ( y_pred == cl_b ) ] plt . figure ( figsize = ( 8 , 8 ) ) plt . subplot ( 221 ) plot_classes ( x_aa [ : 25 ] , images_per_row = 5 ) plt . subplot ( 222 ) plot_classes ( x_ab [ : 25 ] , images_per_row = 5 ) plt . subplot ( 223 ) plot_classes ( x_ba [ : 25 ] , images_per_row = 5 ) plt . subplot ( 224 ) plot_classes ( x_bb [ : 25 ] , images_per_row = 5 ) plt . show ( )
This function plots the images in a 5x5 grid
This function plots the images in a 5x5 grid
"""
    This function plots the images in a 5x5 grid
    :param a: true class label
    :param b: predicted class label
    :param x_train: training data
    :param y_train: training data labels
    :param y_pred: prediction on the test data
    :return: None
    """
None
a
true class label
true class label
b
predicted class label
predicted class label
x_train
None
y_train
training data labels
training data labels
y_pred
prediction on the test data
prediction on the test data