ConeForest
ConeForest is an isolation-style anomaly detector for numeric tabular data. It uses random oblivious trees and JAX array operations to provide fast fitting and scoring on CPUs and GPUs. Higher anomaly scores indicate more anomalous rows.
The project article describes the design, evaluation, ablations, and limitations in detail.
Installation
pip install coneforest
ConeForest requires Python 3.10 or newer. JAX and NumPy are installed as dependencies. To use a GPU, install the appropriate JAX build for your hardware.
Usage
import numpy as np
from coneforest import ConeForest
rng = np.random.default_rng(0)
X_train = rng.normal(size=(1000, 5)).astype(np.float32)
X_test = rng.normal(size=(100, 5)).astype(np.float32)
model = ConeForest(b=256, psi=256, seed=0)
scores = model.fit(X_train).decision_function(X_test)
X_train and X_test are two-dimensional arrays of numeric features. The returned
scores are a one-dimensional NumPy array with one anomaly score per row. To fit and
score the same data in one call, use:
scores = ConeForest(seed=0).fit_predict(X_train)
The constructor accepts three parameters:
b: number of trees, defaulting to 256.psi: maximum number of training rows sampled per tree, defaulting to 256.seed: seed controlling all random draws, defaulting to 0.
No feature scaling or rank transformation is applied. ConeForest returns continuous anomaly scores; choosing a decision threshold is left to the application.
Design
Each tree is oblivious: all nodes at a given level use the same feature and
threshold. A tree of depth K therefore consists of only K feature-threshold pairs,
and each row's leaf is represented by a K-bit code.
For each tree, fitting:
- Samples up to
psitraining rows and setsK = ceil(log2(m)), wheremis the sample size. - Draws one feature per level, with replacement, and a threshold uniformly from that feature's observed range in the sample.
- Converts every sampled row to its cell code and counts the rows in each cell at every depth.
- Smooths each cell's mass as
(count + 1) / (m + 2)and stores, for every full-depth code, the mean negative log mass of its prefix cells.
Scoring computes a row's cell code in each tree, retrieves the precomputed score with
one table lookup per tree, and averages the results. There is no per-node tree traversal
or branching. Fitting touches at most b × psi rows regardless of the full training-set
size, while scoring costs b × K comparisons and b lookups per row.
License
ConeForest is distributed under the GNU General Public License v3.0.
Metadata
Release files for coneforest 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| coneforest-0.1.0.tar.gz | 38.0 kB | Without provenance | Details for coneforest-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coneforest-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for coneforest-0.1.0-py3-none-any.whl |
Total release size: 54.9 kB
Release files / coneforest-0.1.0.tar.gz
| Download URL | coneforest-0.1.0.tar.gz |
|---|---|
| Size | 38.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6563b9d8f214dcc354305108ae36af88f0dd389da4b38cd0dec6beaf8ffb2179
|
|
BLAKE2b-256 checksum How to use checksums |
2a4e1097daa5231942caf56069969da864d74f691386d62486af2d1cf080c4a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / coneforest-0.1.0-py3-none-any.whl
| Download URL | coneforest-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27cb6b6c079634d0d80e1c11bf2c60d245ef7c15b002b51e308e1fea4b20b752
|
|
BLAKE2b-256 checksum How to use checksums |
2be6d394e811382cc1fbf36c34695c22b9f01fc25c14a2cd4c0e8f904328d0c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for coneforest 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.