Package: coniferest
coniferestPackage for active anomaly detection with isolation forests, made bySNAD collaboration.It includes:IsolationForest- reimplementation of scikit-learn's isolation forest with much better scoring performance due to the use of Cython and multi-threading (the latter is not currently available on macOS).AADForest- reimplementation of Active Anomaly detection algorithm with isolation forests from Shubhomoy Das'ad_examplespackagewith better performance, much less code and more flexible dependencies.PineForest- our own active learning model based on the idea of tree filtering.Install the package withpip install coniferest.See the documentation for theTutorial.InstallationThe project is usingCythonfor performance and requires compilation.
However, binary wheels are available for Linux, macOS and Windows, so you can install the package withpip install conifereston these platforms with no build-time dependencies.
Currently multithreading is not available in macOS ARM wheels, but you can install the package from the source to enable it, see instructions below.If your specific platform is not supported, or you need a development version, you can install the package from the source.
To do so, clone the repository and runpip install .in the root directory.Note, that we are using OpenMP for multi-threading, which is not available on macOS with the Apple LLVM Clang compiler.
You still can install the package with Apple LLVM, but it will be single-threaded.
Alternatively, you can install the package with Clang from Homebrew (brew install llvm libomp) or GCC (brew install gcc), which will enable multi-threading.
In this case you will need to set environment variablesCC=gcc-12(or whatever version you have installed) orCC=$(brew --preifx llvm)/bin/clangandCONIFEREST_FORCE_OPENMP_ON_MACOS=1.DevelopmentYou can install the package in editable mode withpip install -e .[dev]to install the development dependencies.Linters and formattersThis project makes use ofpre-commithooks, you can install them withpre-commit install.Pre-commit CIis used for continuous integration of the hooks, they are applied to every pull request, and CI is responsible for auto-updating the hooks.Testing and benchmarkingWe usetoxto build and test the package in isolated environments with different Python versions.
To run tests locally, install tox withpip install toxand runtoxin the root directory.
We configuretoxto skip long tests.The project usespytestas a testing framework.
Tests are located in thetestsdirectory, and can be run withpytest testsin the root directory.
By default, all tests are run, but you can select specific tests with-koption, e.g.pytest tests -k test_onnx.test_onnx_aadforest.
You can also deselect a specific group of tests with-moption, e.g.pytest tests -m'not long', seepyproject.tomlfor the list of markers.We usepytest-benchmarkfor benchmarking.
You can run benchmarks withpytest tests --benchmark-enable -m benchmarkin the root directory.
You can adjust the minimum number of iterations with--benchmark-min-roundsand maximum execution time per benchmark with--benchmark-max-time(note that the latter can be exceeded if the minimum number of rounds is not reached).
Seepyproject.tomlfor the default benchmarking options.
You can make a snapshot the current benchmark result with--benchmark-save=NAMEor with--benchmark-autosave, and compare benchmarks withpytest-benchmark comparecommand.