-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6951c3f
commit 7bda0ed
Showing
1 changed file
with
5 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Example of combining multiple base outlier scores. Four combination | ||
frameworks are demonstrated: | ||
1. Average: take the average of all base detectors | ||
2. maximization : take the maximum score across all detectors as the score | ||
3. Average of Maximum (AOM) | ||
4. Maximum of Average (MOA) | ||
""" | ||
# Author: Yue Zhao <[email protected]> | ||
# License: BSD 2 clause | ||
|
@@ -21,13 +16,9 @@ | |
sys.path.append( | ||
os.path.abspath(os.path.join(os.path.dirname("__file__"), '..'))) | ||
|
||
import numpy as np | ||
from sklearn.model_selection import train_test_split | ||
from scipy.io import loadmat | ||
|
||
from pyod.models.knn import KNN | ||
from pyod.models.combination import aom, moa, average, maximization, median | ||
from pyod.utils.utility import standardizer | ||
from pyod.utils.data import generate_data | ||
from pyod.utils.data import evaluate_print | ||
|
||
|
@@ -39,8 +30,7 @@ | |
# Generate some data if the source data is missing | ||
|
||
for mat_file in file_list: | ||
# mat_file = 'cardio.mat' | ||
# mat_file = 'letter.mat' | ||
|
||
try: | ||
mat = loadmat(os.path.join('data', mat_file)) | ||
|
||
|
@@ -56,7 +46,9 @@ | |
X = mat['X'] | ||
y = mat['y'].ravel() | ||
|
||
clf = KNN() | ||
clf.fit(X) | ||
clf = KNN() # the algorithm you want to check | ||
# clf = KNN_new() | ||
clf.fit(X) # fit model | ||
|
||
# print performance | ||
evaluate_print(mat_file, y, clf.decision_scores_) |