def test_k_nearest_neighbours(self): X, y = compute_moves_v2_without_duplicates() X, y = eliminate_duplicates(X, y) # split training and test data (test size 20%) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1234) acc = k_nearest_neighbours(X_train, X_test, y_train, y_test)
def test_multilayer_perceptron(self): X, y = compute_moves_v2_without_duplicates() X, y = eliminate_duplicates(X, y) # split training and test data (test size 20%) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1234) acc = multilayer_perceptron(X_train, X_test, y_train, y_test)
def test_logistic_regression(self): X, y = compute_moves_v2_without_duplicates() X, y = eliminate_duplicates(X, y) # split training and test data (test size 20%) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1234) acc = logistic_regression(X_train, X_test, y_train, y_test)
def test_accuracies(self): accuracies = [] classifiers = [ 'lin_svm', 'k_n_neighb', 'dec_tree', 'log_regr', 'naive_bayes', 'mlp' ] X, y = compute_moves_v2_without_duplicates() X, y = eliminate_duplicates(X, y) # split training and test data (test size 20%) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1234) acc = linear_svm(X_train, X_test, y_train, y_test) accuracies.append(acc) acc = k_nearest_neighbours(X_train, X_test, y_train, y_test) accuracies.append(acc) acc = decision_tree(X_train, X_test, y_train, y_test) accuracies.append(acc) acc = logistic_regression(X_train, X_test, y_train, y_test) accuracies.append(acc) acc = naive_bayes(X_train, X_test, y_train, y_test) accuracies.append(acc) acc = multilayer_perceptron(X_train, X_test, y_train, y_test) accuracies.append(acc) plt.bar(classifiers, accuracies) # Namimg the x and y axis plt.xlabel('Classifiers') plt.ylabel('Accuracies') # Giving the tilte for the plot plt.title('Accuracies of our Classifiers') # Saving the plot as a 'png' # plt.savefig('ACCPlot.png') plt.show() print(accuracies) print(classifiers) assert True
def test_eliminate_duplicates(self): X, y = compute_moves_v2_without_duplicates() X, y = eliminate_duplicates(X, y) print('X: ', X, 'y: ', y) assert X.shape[0] == y.shape[0]