from import evaluate_print
from pyod.utils.example import visualize


# Loop for outlier detection tools
for i, (clf_name, clf) in enumerate(classifiers.items()):
    # train kNN detector
    # get the prediction labels and outlier scores of the training data
    Y_train_pred = clf.labels_  # binary labels (0: inliers, 1: outliers)
    Y_train_scores = clf.decision_scores_  # raw outlier scores
    # get the prediction on the test data
    Y_test_pred = clf.predict(X_test)  # outlier labels (0 or 1)
    Y_test_scores = clf.decision_function(X_test)  # outlier scores
    # evaluate and print the results
    print("\nOn Training Data:")
    evaluate_print(clf_name, Y_train, Y_train_scores)
    print("\nOn Test Data:")
    evaluate_print(clf_name, Y_test, Y_test_scores)
    # visualize the results
    visualize(clf_name, X_train, Y_train, X_test, Y_test, Y_train_pred,
              Y_test_pred, show_figure=True, save_figure=True)