Skip to content

Python implementation of the local outlier factor tuning algorithm described in “Automatic Hyperparameter Tuning Method for Local Outlier Factor, with Applications to Anomaly Detection.”, Z. Xu, D. Kakde, and A. Chaudhuri - 2019 IEEE International Conference on Big Data (Big Data), 2019.

License

Notifications You must be signed in to change notification settings

vsatyakumar/automatic-local-outlier-factor-tuning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation

Automatic-Local-Outlier-Factor-Tuning :

This repository is an implementation of the algorithm presented in the attached reference publication. Hope you find this useful in your projects. Thanks to the authors for sharing their ideas.

Check this video out for a demo of the tuning in action! Automatic LOF Tuning Demo

Automatic LOF Tuning Demo

Requirements

Download lof_tuner.py to your working directory and import everything.

Usage

Initialize the tuner with your input 'data' or 'n_samples'. If no data is provided, 'n_samples' of datapoints are sampled from an isotropic gaussian distribution for running the tuner test. The optimal configuration of LOF hyperparameter 'K' - neighbors and 'C' - contamination factor is one that maximizes 'Z', and is indicated by the frame with grey circles drawn around the datapoints in the attached video) -

import lof_tuner
from lof_tuner import LOF_AutoTuner

#TEST LOF MODEL TUNER 
#-----------------
#init tuner
tuner = LOF_AutoTuner(n_samples = 500, k_max = 50, c_max = 0.1)

#view grid of hyperparameter values
print(tuner.k_grid) #neighbors
print(tuner.c_grid) #contamination

#test tuner
tuner.test()

#OR TUNE MODEL ON YOUR DATA 
#-----------------
#tune on your custom dataset -> Input 'data', array-like, shape : (n_samples, n_features)
tuner = LOF_AutoTuner(data = data, k_max = 50, c_max = 0.1)

#run tuner
tuner.run()

#TO VISUALISE 
#-----------------
tuner.visualise() #not required when running tuner.test()

#save tuning animation
tuner.animation.save('./lof_tuner_demo.mp4', fps = 2)

References

Automatic Hyperparameter Tuning Method for Local Outlier Factor, with Applications to Anomaly Detection (https://arxiv.org/abs/1902.00567)

Contact

To ask questions or report issues, please open an issue on the issues tracker.

About

Python implementation of the local outlier factor tuning algorithm described in “Automatic Hyperparameter Tuning Method for Local Outlier Factor, with Applications to Anomaly Detection.”, Z. Xu, D. Kakde, and A. Chaudhuri - 2019 IEEE International Conference on Big Data (Big Data), 2019.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages