Computer Vision News - March 2019

22 Computer Vision News Focus on import numpy as np from scipy import stats import matplotlib . pyplot as plt from pyod . models . abod import ABOD from pyod . models . knn import KNN from pyod . models . loci import LOCI from pyod . models . iforest import IForest from pyod . models . feature_bagging import FeatureBagging from pyod . utils . data import generate_data , get_outliers_inliers # random data X_train , Y_train = generate_data ( n_train = 500 , train_only = True , n_features = 2 ) # store outliers and inliers in different numpy arrays n_outliers , n_inliers = list ( map ( len , get_outliers_inliers ( X_train , Y_train ))) x1_outliers , x1_inliers = get_outliers_inliers ( X_train , Y_train ) xx , yy = np . meshgrid ( np . linspace (- 10 , 10 , 200 ), np . linspace (- 10 , 10 , 200 )) plt . figure ( figsize =( 10 , 10 )) # Test 4 different methods contamination_ = 0.2 classifiers = { 'ABOD' : ABOD ( contamination = contamination_ ), 'KNN' : KNN ( contamination = contamination_ ), 'Bag' : FeatureBagging ( contamination = contamination_ ), 'IForest' : IForest ( contamination = contamination_ ) } for i , ( clf_name , clf ) in enumerate ( classifiers . items ()) : clf . fit ( X_train ) # predict outlier score scores_pred = clf . decision_function ( X_train )*- 1 # predict outlier y_pred = clf . predict ( X_train ) n_errors = ( y_pred != Y_train ). sum () # threshold value outlier threshold = stats . scoreatpercentile ( scores_pred , 75 * contamination_ ) # calculates the raw anomaly t = clf . decision_function ( np . c_ [ xx . ravel (), yy . ravel ()]) * - 1 ZZ = t . reshape ( xx . shape ) Focus on: PyOD

RkJQdWJsaXNoZXIy NTc3NzU=