Ejemplo n.º 1
0
def iris_data_simulation(k_value):
    # read iris dataset
    X_train, y_train, X_test, y_test = import_iris_dataset('new_iris.csv')

    # run Vanilla k-NN classifier on IRIS dataset
    k_NN_iris = KNN(k_value)
    k_NN_iris.training(X_train, y_train)
    iris_prediction = k_NN_iris.prediction(X_test)
    k_NN_iris.evaluation_prediction(iris_prediction, y_test)

    # run kernel k-NN classifier on IRIS dataset
    kernel_k_NN_iris = KernelKNN(k_value)
    kernel_k_NN_iris.training(X_train, y_train)
    predicted_iris = kernel_k_NN_iris.prediction(X_test, 'gaussian')
    kernel_k_NN_iris.evaluation_prediction(predicted_iris, y_test)
Ejemplo n.º 2
0
def cifar10_simulation(k_value):
    # import CIFAR10 dataset
    X_train, y_train, X_test, y_test = import_dataset()

    # run Vanilla k-NN classifier on CIFAR10
    k_NN_cifar = KNN(k_value)
    k_NN_cifar.training(X_train, y_train)
    cifar_prediction = k_NN_cifar.prediction(X_test)
    k_NN_cifar.evaluation_prediction(cifar_prediction, y_test)

    # run kernelized k-NN classifier on CIFAR10
    kernel_k_NN_cifar = KernelKNN(k_value)
    kernel_k_NN_cifar.training(X_train, y_train)
    predicted_cifar = kernel_k_NN_cifar.prediction(X_test, 'gaussian')
    kernel_k_NN_cifar.evaluation_prediction(predicted_cifar, y_test)
Ejemplo n.º 3
0
def mnist_simulation(k_value):
    # import MNIST dataset
    mnist_train, mnist_train_label = import_mnist_dataset(
        'mnist_train.csv', 60000)
    mnist_test, mnist_test_label = import_mnist_dataset('mnist_test.csv', 1000)

    # run Vanilla k-NN classifier on MNIST
    k_NN_mnist = KNN(k_value)
    k_NN_mnist.training(mnist_train, mnist_train_label)
    mnist_prediction = k_NN_mnist.prediction(mnist_test)
    k_NN_mnist.evaluation_prediction(mnist_prediction, mnist_test_label)

    # run kernel k-NN classifier on MNIST
    kernel_k_NN_mnist = KernelKNN(k_value)
    kernel_k_NN_mnist.training(mnist_train, mnist_train_label)
    predicted_mnist = kernel_k_NN_mnist.prediction(mnist_test, 'gaussian')
    kernel_k_NN_mnist.evaluation_prediction(predicted_mnist, mnist_test_label)