GithubHelp home page GithubHelp logo

bae-sohee / oneclassclassifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from odb9402/oneclassclassifier

0.0 0.0 0.0 5.91 MB

One-class classifiers for anomaly detection (outlier detection)

License: MIT License

Python 100.00%

oneclassclassifier's Introduction

OneClassClassifier

Outlier detection using One-class classifier.

Install

python setup.py install

Usage

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

Adjusting "nu" as the prior knowledge of the proportion of outliers

few_outliers = ocsvm.train(model='ocsvm', nu=0.01) ## 1% outliers assumed
many_outliers = ocsvm.train(model='ocsvm', nu=0.2) ## 20% outliers assumed

Using small subset for training

ocsvm = occ()
ocsvm.X = some_np_array
ocsvm.train(model='isolationForest', sampling=0.1) ## Only 10% of data will be used for training

Implemented Models

occ = occ()
occ.X = some_np_array
occ.train(model='SOMEMODEL')

Notice

  • This module needs the Tensorflow 2.X.X version.

oneclassclassifier's People

Contributors

odb9402 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.