Outlier detection using One-class classifier.
python setup.py install
from occ.occ import *
## Load data
ocsvm = occ()
ocsvm.load_data_mat(file)
"""
Or
ocsvm.load_data_csv(file)
Or
ocsvm.X = some_np_array ##(n_samples, n_features)
"""
## Train the model and get results
ocsvm.train(model='ocsvm', kernel='rbf', norm=True) # If norm=True, data will be normalized(L2)
Y_scores = ocsvm.get_score(norm=True)
Y_hat = ocsvm.predict(norm=True)
## Visualization of the results
occ.show_projection(ocsvm.X, Y_scores, title="Score ocsvm with rbf kernel", markersize=100)
occ.show_projection(ocsvm.X, Y_hat, title="Prediction ocsvm with rbf kernel", markersize=100)
## Export the result score and outliers
ocsvm.export_outliers("outliers.csv", Y_hat) ## Raw data of outliers
ocsvm.export_csv("scores.csv", Y_scores) ## Raw data with scores
ocsvm.export_csv("predictions.csv", Y_hat) ## Raw data with predictions
few_outliers = ocsvm.train(model='ocsvm', nu=0.01) ## 1% outliers assumed
many_outliers = ocsvm.train(model='ocsvm', nu=0.2) ## 20% outliers assumed
ocsvm = occ()
ocsvm.X = some_np_array
ocsvm.train(model='isolationForest', sampling=0.1) ## Only 10% of data will be used for training
occ = occ()
occ.X = some_np_array
occ.train(model='SOMEMODEL')
- deepsvdd : Deep-SVDD; Deep One-Class Classification [ICML2018; Ruff, Lukas et al.,] ; Tensorflow2 implementation
- autoEncoder : AutoEncoder and reconstruction loss; pyod library
- vae : Variational AutoEncoder and reconstruction loss; pyod library
- isoForest : Isolation Forest; Isolation Forest[IEEE data mining conf 2008; Liu, Fei Tony, Kai Ming Ting, and Zhi-Hua Zhou.]; scikit-learn library
- ocnn : One-Class Neural Networks; Anomaly Detection Using One-Class Neural Networks [Chalapathy, R., Menon, A. K., & Chawla, S.]; Tensorflow2 implementation
- ocsvm : One-Class SVM; Support Vector Method for Novelty Detection [NIPS2000; Schölkopf, Bernhard, et al.]; scikit-learn library
- This module needs the Tensorflow 2.X.X version.