A Isolation based anomaly detection algorithms.
Project description
iNNE
iNNE - Isolation-based anomaly detection using nearest-neighbor ensembles.
Based on the paper:
Tharindu R., et al. Isolation-based anomaly detection using nearest-neighbor ensembles. Computational Intelligence (2018)
Matlab code of iNNE:
Introduction to the paper:
Abstract of the paper:
The first successful isolation-based anomaly detector, ie, iForest, uses trees as a means to perform isolation. Although it has been shown to have advantages over existing anomaly detectors, we have identified 4 weaknesses, ie, its inability to detect local anomalies, anomalies with a high percentage of irrelevant attributes, anomalies that are masked by axis-parallel clusters, and anomalies in multimodal data sets. To overcome these weaknesses, this paper shows that an alternative isolation mechanism is required and thus presents iNNE or isolation using Nearest Neighbor Ensemble. Although relying on nearest neighbors, iNNE runs significantly faster than the existing nearest neighbor-based methods such as the local outlier factor, especially in data sets having thousands of dimensions or millions of instances. This is because the proposed method has linear time complexity and constant space complexity.
Documentation, including tutorials, are available on ReadTheDocs at https://inne.readthedocs.io.
Installing
PyPI install, presuming you have an up to date pip.
pip install inne
For a manual install of the latest code directly from GitHub:
pip install git+https://github.com/xhan97/inne.git
Alternatively download the package, install requirements, and manually run the installer:
wget https://codeload.github.com/xhan97/inne/zip/refs/heads/master
unzip inne-master.zip
rm inne-master.zip
cd inne-master
pip install -r requirements.txt
python setup.py install
How to use iNNE
The inne package inherits from sklearn classes, and thus drops in neatly next to other sklearn with an identical calling API. Similarly it supports input in a variety of formats: an array (or pandas dataframe) of shape (num_samples x num_features).
from inne import IsolationNNE
from sklearn.datasets import make_blobs
data, _ = make_blobs(1000)
clf = IsolationNNE(n_estimators=200, max_samples=16)
clf.fit(data)
anomaly_labels = clf.predict(data)
Running the Tests
The package tests can be run after installation using the command:
pip install pytest
or, if pytest is installed:
pytest inne/tests
If one or more of the tests fail, please report a bug at https://github.com/xhan97/inne/issues
Python Version
Python 3 is recommend the better option if it is available to you.
Citing
If you have used this codebase in a scientific publication and wish to cite it, please use the following publication (Bibtex format):
@article{bandaragoda2018isolation,
title={Isolation-based anomaly detection using nearest-neighbor ensembles},
author={Bandaragoda, Tharindu R and Ting, Kai Ming and Albrecht, David and Liu, Fei Tony and Zhu, Ye and Wells, Jonathan R},
journal={Computational Intelligence},
volume={34},
number={4},
pages={968-998},
year={2018},
publisher={Wiley Online Library} }
How to contribute
Thanks for your interest in contributing to inne. A guide is shown in inne’s Documentation.
License
BSD license
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file inne-0.2.0.tar.gz
.
File metadata
- Download URL: inne-0.2.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9373e5bbf5f76729efdef35a3a11a9f2c7770abb91edd7505a9514b855bda92 |
|
MD5 | 4d84b3c6ee6a22b824ed2cef349bf677 |
|
BLAKE2b-256 | 896ecd19e3ad7edad5e7993a176b61a011458d6af260f047e4d1321d73e7503d |
File details
Details for the file inne-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: inne-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebb619b4c9fa8f7b0c0a614524a83a89c5dd08912f88da88cde3da43862fc9c1 |
|
MD5 | ce1bfc130e446ad233d81704b6d3893c |
|
BLAKE2b-256 | 8ef14e6d800fb50b36f30338aafb3de5adf633c8092d7ab38f76eed13862a1b5 |