y_pred = baseline_model.predict(x_test) stop_test = time() print("Accuracy: %.2f%% Training: %.2fs Testing: %.2fs" % (f1_score(y_test, y_pred, average='macro') * 100, stop_train - start_train, stop_test - start_test)) print( pd.crosstab(y_pred, y_test, rownames=['True'], colnames=['Predicted'], margins=True)) print('\nClassification Report:\n', classification_report(y_test, y_pred)) plot_confusion_matrix(confusion_matrix(y_test, y_pred, labels=['win', 'loss', 'draw']), target_names=['win', 'loss', 'draw'], title="Baseline Support-Vector Machine") tuned_model = svm.SVC(decision_function_shape='ovo', C=10, gamma=0.1, kernel='rbf', random_state=42) start_train = time() tuned_model.fit(x_train, y_train) stop_train = time() start_test = time() y_pred = tuned_model.predict(x_test)
x_train, x_test, y_train, y_test = train_test_split(x_transformed, y, test_size=0.20, random_state=42) clf = GaussianNB() start_train = time() clf.fit(x_train, y_train) stop_train = time() start_test = time() y_pred = clf.predict(x_test) stop_test = time() print("Accuracy: %.2f%% Training: %.2fs Testing: %.2fs" % (f1_score(y_test, y_pred, average='macro') * 100, stop_train - start_train, stop_test - start_test)) print( pd.crosstab(y_test, y_pred, rownames=['True'], colnames=['Predicted'], margins=True)) print('\nClassification Report:\n', classification_report(y_test, y_pred)) plot_confusion_matrix(confusion_matrix(y_test, y_pred, labels=['win', 'loss', 'draw']), target_names=['win', 'loss', 'draw'], title="Gaussian Naive Bayes")
tm = MultiClassTsetlinMachine(2000, 80, 2.0, weighted_clauses=True) start_train = time() tm.fit(x_train, y_train, epochs=1, incremental=True) stop_train = time() start_test = time() y_pred = tm.predict(x_test) stop_test = time() print("Accuracy: %.2f%% Training: %.2fs Testing: %.2f" % (f1_score(y_test, y_pred, average='macro'), stop_train - start_train, stop_test - start_test)) print( pd.crosstab(y_test, y_pred, rownames=['True'], colnames=["Predicted"], margins=True)) print('\nClassification Report:\n', classification_report(y_test, y_pred)) y_test = le.inverse_transform(y_test) y_pred = le.inverse_transform(y_pred) plot_confusion_matrix(confusion_matrix(y_test, y_pred, labels=['win', 'loss', 'draw']), target_names=['win', 'loss', 'draw'], title="Optimized Tsetlin Machine")
stop_test = time() print("Baseline") print("Accuracy: %.2f%% Training: %.2fs Testing: %.2fs \n" % (f1_score(y_pred, y_test, average='macro') * 100, stop_train - start_train, stop_test - start_test)) print( pd.crosstab(y_test, y_pred, rownames=['True'], colnames=['Predicted'], margins=True)) print('\nClassification Report:\n', classification_report(y_test, y_pred)) plot_confusion_matrix(confusion_matrix(y_test, y_pred, labels=['win', 'loss', 'draw']), target_names=['win', 'loss', 'draw'], title="Baseline KNN") start_train = time() tuned_model.fit(x_train, y_train) stop_train = time() start_test = time() y_pred = tuned_model.predict(x_test) stop_test = time() print("Tuned") print("Accuracy: %.2f%% Training: %.2fs Testing: %.2fs \n" % (f1_score(y_pred, y_test, average='macro') * 100, stop_train - start_train, stop_test - start_test))