GithubHelp home page GithubHelp logo

ychalier / anomaly Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 7.0 28.25 MB

Classification anomaly detection in IOT with Machine Learning

Home Page: https://perso.telecom-paristech.fr/ychalier/anomaly/

Jupyter Notebook 77.60% Python 5.64% TeX 16.76%
iot machine-learning classification anomaly-detection

anomaly's Introduction

anomaly

Classification anomaly detection in IOT with Machine Learning

See this notebook for an example of our work.

setup

use a virtual environment with Python 3.6 and install the modules from requirements.txt.

python -m virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

usage

You only need two files, detector.py contains the Detector that is used to store and compute datasets. A example of its usage is shown in main.ipynb.

One may use scp to copy databases over a distant server to execute code.

scp *.csv user@host:path/

parameters tuning

In order to find the best parameters for each classifier, we use a grid search with cross validation to find the best set of parameters. The class Detector now has a method called tune_parameters which seeks the best set of selected parameters for a given classifier. This method is used in a small Python script called parameters.py that can be run on more powerful servers.

This script outputs a .out file that then can be exported as JSON and/or CSV using beautify.py. You can find examples of those files here.

CSV files are formatted such that a single test batch is split in several files:

  • .scores.csv: the detailed scores for each test (including the confusion matrix), along with the unique parameters combination id.
  • .params.estimatorName.csv: for each type of classifier, the value of each parameter for every combination using this classifier, along with the combination id used as a foreign key with the scores table.

Side note: the delimiter for those CSV file is currently ;.

The script process_output.py processes thoses CSV files to produce relevant plots. Here is an example:

Parameters tuning for MLP

usage in production

The following notebook shows how to generate the prediction function. Then, the following script only need this file to classify whether the given record is an anomaly or not:

def classify(class_, length, width):
  import pickle
  file = open('anomaly_classifier.clf', 'rb')
  fun = pickle.load(file)
  file.close()
  if fun(class_, length, width):
      return "malicious"
  else:
      return "non-malicous"

anomaly's People

Contributors

antoineurban avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.