ecod-rs
The ECOD outlier detector (Li et al., 2022) in Rust, with Python bindings.
- Install
- Quick start
- ECOD vs InductiveECOD
- Constructor
- How scores are computed
- Scores, labels and probabilities
- Methods
- Input data
- Parallelism
- Saving and loading
- Errors
- Benchmark
Install
Requires Python 3.12+.
pip install ecod-rs
Quick start
import numpy as np
from ecod_rs import InductiveECOD
rng = np.random.default_rng(0)
X_train = rng.normal(size=(1000, 10))
X_test = rng.normal(size=(200, 10))
model = InductiveECOD(contamination=0.1).fit(X_train)
scores = model.decision_function(X_test) # higher means more anomalous
labels = model.predict(X_test) # 1 is an outlier
proba = model.predict_proba(X_test) # (n, 2): [inlier, outlier]
model.save("model.bin")
model = InductiveECOD.load("model.bin")
ECOD vs InductiveECOD
Both classes have the same interface. They differ in what a score depends on.
InductiveECOD | ECOD | |
|---|---|---|
fit | Sorts every feature of the training data and stores it. | Same. |
| Scoring | Each sample is compared with the training data only. Its score does not depend on the rest of the batch. | The batch is merged with the training data and every distribution is rebuilt, as in PyOD. A sample's score depends on the whole batch. |
| Use when | Scoring new data in production, one sample or many. | You need numbers that match PyOD. |
In PyOD, fit only stores the data, so its ECOD is always transductive (see PyOD issues #401 and #426). InductiveECOD is the variant PyOD does not have.
Constructor
InductiveECOD(contamination=0.1, method="max", n_jobs=1)
ECOD(contamination=0.1, method="max", n_jobs=1)
| Parameter | Default | Description |
|---|---|---|
contamination | 0.1 | Expected share of outliers, in (0, 0.5]. Only predict uses it, see predict. |
method | "max" | One of "max", "pyod-max", "left", "right", "auto". How per-feature tail probabilities are combined into a score, see Score methods. |
n_jobs | 1 | Number of threads. 0 uses all cores. See Parallelism. |
How scores are computed
ECOD looks at every feature separately. For a value it asks how rare it is in the left tail (values this low or lower) and in the right tail (values this high or higher), then adds the negative logs over all features. Notation: the training data has rows and features, is feature of training row , and is the sample being scored.
Tail probabilities
InductiveECOD counts training values only. One is added to the count and to the total, so a value outside the training range gets a small probability instead of zero:
ECOD counts over , the training values of feature together with the batch being scored, values in total for a batch of rows. The sample itself is in , so the counts are at least one:
Skewness
The "auto" and "max" methods pick a tail per feature by the sign of its sample skewness. InductiveECOD computes it on the training data at fit, ECOD on for every batch:
A constant feature has and gets .
Tail scores
Three sums over features: left tail, right tail, and the tail picked by skewness.
Tail probabilities are at most 1, so all scores are non-negative. With one tail, a normal sample scores about on average, because of a uniform value averages 1. The "max" and "pyod-max" methods give higher numbers on the same data. A sample that sits in the tails of many features scores much higher than any of these.
Score methods
The method parameter picks the final score :
method | Score | When to use |
|---|---|---|
"max" |
Default, as in the paper. The maximum is taken over the three whole sums. | |
"pyod-max" |
Reproduces PyOD's numbers. PyOD takes the maximum per feature, before summing, which is always at least the paper's score. | |
"left" |
Only unusually low values matter. | |
"right" |
Only unusually high values matter, for example latencies or amounts. | |
"auto" |
One tail per feature, the long one. |
Scores, labels and probabilities
A fitted model gives three kinds of output for the same samples. All three come from the same score ; they differ in what they add on top of it.
decision_function | predict | predict_proba(method="linear") | predict_proba(method="unify") | |
|---|---|---|---|---|
| Returns | Score, a float >= 0 | Label, 0 or 1 | [inlier, outlier], floats in [0, 1] | [inlier, outlier], floats in [0, 1] |
Uses contamination | No | Yes, sets the threshold | No | No |
| Uses training scores | No | Their percentile | Their min and max | Their mean and std |
| Keeps the order of scores | - | Only above or below the threshold | Yes, until clipped at 0 or 1 | Yes, until clipped at 0 or 1 |
| Good for | Ranking samples, ROC AUC, your own threshold | A yes/no decision at a known outlier rate | Comparing scores on a fixed scale | Calibrated-looking probabilities, as in PyOD |
At fit, the model scores its own training data once and stores four numbers from those training scores: the threshold, the minimum and maximum, and the mean and standard deviation. predict and predict_proba compare new scores with them.
decision_function
Returns for every row, nothing else. Higher means more anomalous. This is the output to use for ranking and for metrics such as ROC AUC, since it loses no information.
predict
The threshold is the -th percentile of the training scores, where is contamination. The percentile uses linear interpolation, like numpy.percentile by default. A row is an outlier when its score is above the threshold:
So on the training data about a share of rows is labelled 1. On new data the share can be anything: it is the share of rows that score above the training percentile. contamination does not change scores or probabilities, only this threshold.
predict_proba
Turns the score into an outlier probability and returns per row, an array of shape (n_samples, 2) like in PyOD and scikit-learn. Both methods clip to . With , , and the minimum, maximum, mean and standard deviation of the training scores:
"linear"maps the training score range onto [0, 1]. Every score above the largest training score gets 1, so it cannot tell a slightly unusual new sample from an extreme one. If all training scores are equal, the range is taken as 1."unify"gives exactly 0 to every score below the training mean, since is negative there. Scores are skewed to the right, so usually more than half of normal samples get 0: 58% in a test on normal noise. Above the mean it rises quickly: two standard deviations above the mean gives about 0.95.- is the population standard deviation, like
numpy.stdwith the defaultddof=0.
predict and predict_proba can disagree
predict uses the contamination threshold, predict_proba does not. A row labelled 1 can have an outlier probability below 0.5, and the other way round. In a quick check with 500 training and 50 test rows of normal noise, predict_proba(x)[:, 1] > 0.5 differed from predict(x) on 4 rows. If you need labels, use predict; if you need your own cut-off, threshold decision_function.
ECOD and the batch
For ECOD all three outputs depend on the batch, because the score does. The same row gets a different score, label and probability when scored alone and when scored together with other rows. The stored training statistics stay fixed, so only the score side moves.
Scoring the training data again with ECOD.decision_function(X_train) gives the same scores as fit: merging the data with a copy of itself doubles every count and the total, so the ratios do not change. These are also the numbers PyOD stores in decision_scores_ with method="pyod-max".
InductiveECOD has none of this: a row gets the same output alone or in any batch.
Methods
fit(x) -> self
Fits the model on x of shape (n_samples, n_features) and returns the model itself, so calls can be chained.
decision_function(x) -> list[float]
Score of each row. See decision_function.
predict(x) -> list[int]
Label of each row, 1 for outliers. See predict.
predict_proba(x, method="linear") -> list[[float, float]]
[inlier, outlier] probabilities of each row, method is "linear" or "unify". See predict_proba.
save(path, *, compression_level=None)
Writes the fitted model to a file. See Saving and loading.
load(path, *, n_jobs=1) -> model
Static method. Reads a model saved by the same class.
For every method that takes x, it must have the same number of features as the training data.
Input data
- A 2-D numpy
float64array is read in place, without a copy. Non-contiguous views such as slices and transposes work too. - Other dtypes and lists of lists are converted to
float64first, which costs a copy. - Values must be finite:
NaNandinfraiseValueError. - Results are returned as Python lists; wrap them in
np.asarrayif you need an array.
Parallelism
n_jobs sets the number of threads for fit, decision_function, predict and predict_proba.
1(default): one thread. Good for small data, and when the model already runs inside parallel code such asGridSearchCV(n_jobs=-1)or joblib.0: all cores.n > 0:nthreads.- Negative values raise
ValueError.-1does not mean all cores here, unlike in scikit-learn.
Scores are bit-identical for any n_jobs. Each model keeps its own thread pool for its lifetime. The GIL is released during computation, so Python threads can run other work in parallel.
On 100,000 rows and more, all cores are 4 to 7 times faster than one thread. Around 10,000 rows it is about 2 times faster, and for tiny inputs starting the pool in the constructor costs more than it saves. See the benchmark.
Saving and loading
model.save("model.bin") # zstd level 3
model.save("model.bin", compression_level=19) # smaller file, slower save
model = InductiveECOD.load("model.bin", n_jobs=0)
- The file is the model compressed with zstd.
compression_levelis a zstd level: higher means a smaller file and a slower save, negative values are faster than the default. n_jobsis not stored in the file: a model saved on one machine can be loaded on another with its own thread count.- The model is checked on load. A damaged file raises
ValueErrororRuntimeError(see Errors) instead of producing wrong scores.
Errors
| Exception | When |
|---|---|
ValueError | Invalid contamination, method or n_jobs; empty input; rows of different lengths; NaN or inf in the input; wrong number of features passed to a fitted model; a model file that cannot be decoded or fails the checks. |
RuntimeError | Calling decision_function, predict, predict_proba or save before fit; zstd failing to compress or decompress. |
OSError | File errors in save and load, such as FileNotFoundError or PermissionError. |
Benchmark
ecod-rs compared with ECOD from PyOD.
Data is random normal noise of several sizes (rows x features) and the classical datasets from
ADBench. Each dataset is split 60/40 into train and test.
Every measurement runs in a fresh process, times are taken over 5 runs.
All tables except Parallelism use one thread: n_jobs=1 for both libraries.
What is measured:
- fit: training, including conversion from numpy;
- score: scoring the test part with a fitted model;
- pipeline: fit and score together;
- convert: passing data into ecod-rs up to input validation;
- save and load: writing and reading a model file. The default and compressed variants are zstd levels 3 and 19 for ecod-rs, joblib levels 0 and 3 for PyOD.
Summary
How many times ecod-rs is faster than pyod-ECOD: median over all 53 datasets, the range in brackets. Below 1 means slower.
| phase | variant | times faster than pyod-ECOD | |
|---|---|---|---|
| ECOD | InductiveECOD | ||
| fit | 4.3x (2.3x to 11.3x) | 4.3x (2.2x to 10.7x) | |
| score | 7.7x (3.9x to 26.7x) | 10.7x (5.8x to 39.7x) | |
| pipeline | 5.7x (2.7x to 18.1x) | 6.6x (3.2x to 19.8x) | |
| save | default | 2.4x (0.4x to 5.3x) | 2.3x (0.4x to 5.3x) |
| save | compressed | 1.7x (0.3x to 19.3x) | 1.7x (0.3x to 18.1x) |
| load | default | 2.7x (0.5x to 4.0x) | 2.7x (0.5x to 4.2x) |
| load | compressed | 24.6x (4.7x to 105.5x) | 24.9x (4.3x to 108.9x) |
Speed
Median time in seconds. In brackets, how many times faster than pyod-ECOD. PyOD has no separate convert step.
| dataset | fit, s | score, s | pipeline, s | convert, s | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | |
| 1000x10 | 0.0005315 (3.1x) | 0.0005719 (2.9x) | 0.00167 | 0.0004201 (4.3x) | 0.0002783 (6.4x) | 0.001795 | 0.0009592 (3.0x) | 0.0007912 (3.7x) | 0.00292 | 0.0001278 | 0.0001273 |
| 10000x10 | 0.003823 (2.3x) | 0.003394 (2.5x) | 0.008634 | 0.002972 (4.8x) | 0.002029 (7.0x) | 0.01416 | 0.006267 (3.7x) | 0.004784 (4.9x) | 0.02329 | 0.0001288 | 0.0001476 |
| 100000x10 | 0.03551 (2.9x) | 0.03621 (2.9x) | 0.1044 | 0.03009 (6.1x) | 0.0157 (11.7x) | 0.1833 | 0.06694 (4.3x) | 0.05167 (5.5x) | 0.2864 | 0.0001298 | 0.0001327 |
| 1000000x10 | 0.4118 (3.6x) | 0.4117 (3.6x) | 1.5 | 0.3141 (8.1x) | 0.177 (14.4x) | 2.546 | 0.7523 (5.4x) | 0.5904 (6.8x) | 4.036 | 0.000141 | 0.0001601 |
| 10000x100 | 0.03111 (2.8x) | 0.03004 (2.8x) | 0.08557 | 0.02799 (5.1x) | 0.01417 (10.0x) | 0.1414 | 0.059 (3.9x) | 0.04392 (5.2x) | 0.2304 | 0.0001576 | 0.0001554 |
| 100000x100 | 0.3506 (3.5x) | 0.3378 (3.6x) | 1.228 | 0.3004 (7.2x) | 0.1561 (13.8x) | 2.159 | 0.6526 (5.2x) | 0.4928 (6.9x) | 3.384 | 0.0001386 | 0.0001484 |
ADBench datasets
| dataset | fit, s | score, s | pipeline, s | convert, s | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | |
| 1_ALOI | 0.02566 (6.3x) | 0.02615 (6.2x) | 0.1629 | 0.02053 (14.7x) | 0.01349 (22.4x) | 0.3016 | 0.04615 (10.3x) | 0.03959 (12.0x) | 0.4732 | 0.0001259 | 0.0001496 |
| 2_annthyroid | 0.001216 (3.7x) | 0.0009853 (4.5x) | 0.004473 | 0.0008928 (7.6x) | 0.0006369 (10.7x) | 0.006815 | 0.001903 (5.8x) | 0.001485 (7.4x) | 0.01098 | 0.0001349 | 0.0001438 |
| 3_backdoor | 0.2502 (10.8x) | 0.2516 (10.7x) | 2.694 | 0.2203 (21.5x) | 0.1223 (38.8x) | 4.745 | 0.4755 (15.6x) | 0.3852 (19.3x) | 7.422 | 0.0001601 | 0.0001629 |
| 4_breastw | 0.0002925 (4.8x) | 0.0002917 (4.8x) | 0.001394 | 0.00018 (8.7x) | 0.0001561 (10.0x) | 0.001568 | 0.0004111 (6.4x) | 0.0003836 (6.8x) | 0.002614 | 0.0001343 | 0.0001657 |
| 5_campaign | 0.03005 (10.7x) | 0.03065 (10.5x) | 0.3212 | 0.02175 (26.7x) | 0.01582 (36.7x) | 0.5812 | 0.05091 (18.1x) | 0.04641 (19.8x) | 0.9196 | 0.0001636 | 0.0001396 |
| 6_cardio | 0.001143 (3.4x) | 0.001194 (3.3x) | 0.003942 | 0.0008923 (6.5x) | 0.0006305 (9.2x) | 0.005812 | 0.001681 (5.5x) | 0.001596 (5.8x) | 0.009266 | 0.0001428 | 0.0001607 |
| 7_Cardiotocography | 0.001096 (3.9x) | 0.001044 (4.1x) | 0.004298 | 0.0009031 (7.4x) | 0.0006389 (10.4x) | 0.006673 | 0.001763 (6.0x) | 0.001756 (6.1x) | 0.01064 | 0.0001644 | 0.0001561 |
| 8_celeba | 0.1257 (7.4x) | 0.1291 (7.2x) | 0.9338 | 0.1055 (15.8x) | 0.05969 (28.0x) | 1.671 | 0.2316 (11.3x) | 0.1744 (15.0x) | 2.612 | 0.00015 | 0.000139 |
| 9_census | 2.294 (11.3x) | 2.834 (9.1x) | 25.85 | 1.792 (24.6x) | 1.113 (39.6x) | 44.04 | 4.129 (16.3x) | 3.746 (18.0x) | 67.34 | 0.0001493 | 0.0001468 |
| 10_cover | 0.05276 (6.8x) | 0.05231 (6.8x) | 0.3564 | 0.03673 (17.5x) | 0.02445 (26.3x) | 0.6423 | 0.08875 (11.3x) | 0.07566 (13.3x) | 1.004 | 0.0001659 | 0.000146 |
| 11_donors | 0.09409 (8.3x) | 0.09494 (8.3x) | 0.7836 | 0.06604 (25.5x) | 0.04249 (39.7x) | 1.686 | 0.1766 (14.1x) | 0.145 (17.2x) | 2.497 | 0.0001413 | 0.0001607 |
| 12_fault | 0.001646 (2.8x) | 0.001582 (2.9x) | 0.004554 | 0.001433 (5.3x) | 0.001008 (7.6x) | 0.007628 | 0.002573 (4.4x) | 0.002319 (4.9x) | 0.01135 | 0.0001414 | 0.000144 |
| 13_fraud | 0.3173 (3.9x) | 0.3217 (3.8x) | 1.232 | 0.2602 (8.2x) | 0.1426 (15.0x) | 2.141 | 0.5858 (5.8x) | 0.453 (7.5x) | 3.39 | 0.0001357 | 0.0001305 |
| 14_glass | 0.0002099 (4.6x) | 0.000219 (4.4x) | 0.0009608 | 0.00009149 (9.2x) | 0.0001093 (7.7x) | 0.0008444 | 0.0003033 (4.9x) | 0.0002557 (5.8x) | 0.001489 | 0.0001492 | 0.0001597 |
| 15_Hepatitis | 0.0001928 (5.0x) | 0.0002041 (4.7x) | 0.0009585 | 0.0001277 (6.4x) | 0.0001073 (7.6x) | 0.0008205 | 0.0002712 (5.5x) | 0.0002332 (6.4x) | 0.001498 | 0.0001454 | 0.0001592 |
| 16_http | 0.03185 (8.1x) | 0.03207 (8.0x) | 0.2572 | 0.02393 (19.6x) | 0.01936 (24.3x) | 0.4696 | 0.0671 (11.0x) | 0.04895 (15.1x) | 0.7369 | 0.0001597 | 0.0001556 |
| 17_InternetAds | 0.03949 (9.1x) | 0.0402 (9.0x) | 0.361 | 0.02643 (24.1x) | 0.01937 (32.9x) | 0.6371 | 0.06324 (16.0x) | 0.05571 (18.2x) | 1.014 | 0.0001384 | 0.0001522 |
| 18_Ionosphere | 0.0005413 (2.6x) | 0.000537 (2.6x) | 0.001388 | 0.0004194 (4.1x) | 0.0002927 (5.9x) | 0.001725 | 0.0009219 (3.0x) | 0.0008246 (3.3x) | 0.002724 | 0.000161 | 0.0001527 |
| 19_landsat | 0.00352 (5.2x) | 0.004246 (4.4x) | 0.01847 | 0.002869 (11.3x) | 0.002217 (14.6x) | 0.03244 | 0.006125 (9.2x) | 0.005312 (10.6x) | 0.05635 | 0.0001515 | 0.0001528 |
| 20_letter | 0.000975 (4.8x) | 0.001073 (4.3x) | 0.004642 | 0.0007548 (8.7x) | 0.0005904 (11.1x) | 0.006556 | 0.00158 (7.0x) | 0.001611 (6.8x) | 0.01102 | 0.0001548 | 0.0001294 |
| 21_Lymphography | 0.000211 (5.0x) | 0.0002053 (5.1x) | 0.001047 | 0.0001328 (7.4x) | 0.0001172 (8.4x) | 0.0009807 | 0.000308 (5.7x) | 0.0002656 (6.6x) | 0.001762 | 0.0001481 | 0.0001395 |
| 22_magic.gamma | 0.006157 (2.7x) | 0.006313 (2.7x) | 0.01682 | 0.005067 (5.7x) | 0.003156 (9.1x) | 0.02887 | 0.01101 (4.6x) | 0.008877 (5.7x) | 0.05059 | 0.0001538 | 0.0001392 |
| 23_mammography | 0.001658 (4.6x) | 0.00157 (4.9x) | 0.007646 | 0.001327 (9.2x) | 0.0009941 (12.3x) | 0.0122 | 0.002577 (8.0x) | 0.002388 (8.6x) | 0.02052 | 0.0001336 | 0.000147 |
| 24_mnist | 0.009274 (7.4x) | 0.009419 (7.3x) | 0.06887 | 0.007249 (16.8x) | 0.005297 (23.1x) | 0.1221 | 0.01621 (12.6x) | 0.01391 (14.7x) | 0.2043 | 0.0001561 | 0.0001643 |
| 25_musk | 0.01084 (3.3x) | 0.01071 (3.3x) | 0.03539 | 0.008963 (8.3x) | 0.005603 (13.3x) | 0.0743 | 0.01946 (6.2x) | 0.01652 (7.3x) | 0.1205 | 0.0001455 | 0.0001549 |
| 26_optdigits | 0.004477 (6.6x) | 0.00399 (7.4x) | 0.0294 | 0.0033 (15.8x) | 0.002686 (19.5x) | 0.05229 | 0.00722 (12.6x) | 0.006128 (14.9x) | 0.09118 | 0.0001383 | 0.0001395 |
| 27_PageBlocks | 0.001744 (3.1x) | 0.002065 (2.6x) | 0.005353 | 0.001549 (5.5x) | 0.001017 (8.3x) | 0.008459 | 0.003273 (4.2x) | 0.002347 (5.9x) | 0.0138 | 0.0001367 | 0.0001573 |
| 28_pendigits | 0.003318 (2.9x) | 0.003131 (3.1x) | 0.00964 | 0.00258 (6.2x) | 0.001814 (8.9x) | 0.01608 | 0.005783 (4.7x) | 0.004654 (5.8x) | 0.027 | 0.0001601 | 0.0001585 |
| 29_Pima | 0.000348 (3.7x) | 0.0003688 (3.5x) | 0.001297 | 0.0002529 (5.6x) | 0.0001918 (7.3x) | 0.001408 | 0.0005971 (4.1x) | 0.0004978 (4.9x) | 0.002457 | 0.00015 | 0.0001551 |
| 30_satellite | 0.003673 (4.7x) | 0.003667 (4.7x) | 0.01729 | 0.003125 (10.4x) | 0.002159 (15.1x) | 0.03252 | 0.006303 (8.9x) | 0.00553 (10.1x) | 0.05608 | 0.0001462 | 0.0001398 |
| 31_satimage-2 | 0.003177 (5.1x) | 0.003303 (4.9x) | 0.01615 | 0.002849 (10.0x) | 0.001951 (14.6x) | 0.0284 | 0.005586 (8.8x) | 0.004752 (10.4x) | 0.04942 | 0.0001644 | 0.0001566 |
| 32_shuttle | 0.005558 (8.3x) | 0.00611 (7.5x) | 0.04593 | 0.004434 (19.6x) | 0.003482 (25.0x) | 0.087 | 0.009897 (14.7x) | 0.008737 (16.7x) | 0.146 | 0.0001332 | 0.0001331 |
| 33_skin | 0.0125 (6.8x) | 0.01244 (6.8x) | 0.08481 | 0.009144 (16.1x) | 0.007109 (20.7x) | 0.1471 | 0.02667 (9.3x) | 0.01964 (12.6x) | 0.2471 | 0.0001534 | 0.0001407 |
| 34_smtp | 0.005404 (5.5x) | 0.005841 (5.1x) | 0.02985 | 0.004179 (13.7x) | 0.002989 (19.2x) | 0.05739 | 0.01104 (8.4x) | 0.008255 (11.2x) | 0.09277 | 0.0001401 | 0.0001456 |
| 35_SpamBase | 0.004272 (6.0x) | 0.003894 (6.6x) | 0.02573 | 0.003121 (15.6x) | 0.002025 (24.1x) | 0.04872 | 0.006433 (12.7x) | 0.005773 (14.1x) | 0.08147 | 0.0001442 | 0.0001334 |
| 36_speech | 0.04189 (2.6x) | 0.04211 (2.6x) | 0.1102 | 0.03511 (6.1x) | 0.02077 (10.3x) | 0.2133 | 0.07649 (4.6x) | 0.06242 (5.6x) | 0.3516 | 0.0001581 | 0.0001558 |
| 37_Stamps | 0.0002822 (3.8x) | 0.0002803 (3.8x) | 0.00106 | 0.0001876 (5.4x) | 0.0001398 (7.3x) | 0.001015 | 0.0004576 (3.9x) | 0.0003734 (4.8x) | 0.001792 | 0.0001374 | 0.0001459 |
| 38_thyroid | 0.0007609 (3.7x) | 0.0007694 (3.7x) | 0.002816 | 0.000557 (7.2x) | 0.0003719 (10.9x) | 0.004035 | 0.001279 (5.1x) | 0.001122 (5.9x) | 0.006576 | 0.0001572 | 0.0001312 |
| 39_vertebral | 0.0002272 (4.2x) | 0.0002263 (4.2x) | 0.0009611 | 0.0001359 (6.2x) | 0.0001132 (7.4x) | 0.0008362 | 0.0003065 (4.9x) | 0.0002624 (5.7x) | 0.001489 | 0.000159 | 0.0001412 |
| 40_vowels | 0.0008657 (2.3x) | 0.0009013 (2.2x) | 0.00198 | 0.0006683 (3.9x) | 0.0004288 (6.1x) | 0.002602 | 0.001542 (2.7x) | 0.001295 (3.2x) | 0.004179 | 0.0001709 | 0.0001426 |
| 41_Waveform | 0.002339 (2.6x) | 0.002667 (2.3x) | 0.006038 | 0.002166 (4.5x) | 0.001435 (6.7x) | 0.009671 | 0.004341 (3.4x) | 0.003633 (4.1x) | 0.01494 | 0.0001437 | 0.0001515 |
| 42_WBC | 0.0001952 (5.2x) | 0.0002114 (4.8x) | 0.001016 | 0.0001196 (7.7x) | 0.0001074 (8.5x) | 0.0009153 | 0.0002839 (5.7x) | 0.0002598 (6.3x) | 0.001624 | 0.0001384 | 0.0001434 |
| 43_WDBC | 0.0005823 (2.5x) | 0.0005833 (2.5x) | 0.001467 | 0.0004626 (3.9x) | 0.0003041 (5.9x) | 0.001793 | 0.0009953 (3.0x) | 0.0008422 (3.5x) | 0.002968 | 0.000149 | 0.0001586 |
| 44_Wilt | 0.001165 (2.5x) | 0.001024 (2.9x) | 0.002942 | 0.0009445 (4.4x) | 0.0005989 (7.0x) | 0.004177 | 0.001721 (4.0x) | 0.001748 (3.9x) | 0.006851 | 0.0001549 | 0.0001658 |
| 45_wine | 0.0002256 (4.3x) | 0.0002281 (4.3x) | 0.0009729 | 0.0001447 (6.0x) | 0.0001163 (7.5x) | 0.0008703 | 0.000308 (4.9x) | 0.0002768 (5.4x) | 0.0015 | 0.0001584 | 0.0001606 |
| 46_WPBC | 0.0004005 (3.0x) | 0.0004293 (2.8x) | 0.001215 | 0.0003016 (4.2x) | 0.0002177 (5.8x) | 0.001272 | 0.0006609 (3.3x) | 0.0005729 (3.8x) | 0.002175 | 0.0001665 | 0.0001597 |
| 47_yeast | 0.0004359 (4.3x) | 0.0004418 (4.3x) | 0.00189 | 0.0003013 (8.1x) | 0.0002342 (10.5x) | 0.002451 | 0.0007134 (5.6x) | 0.0006608 (6.1x) | 0.004012 | 0.0001353 | 0.0001503 |
Memory
How much the process memory peak grew during the run, in MB.
| dataset | fit, MB | score, MB | ||||
|---|---|---|---|---|---|---|
| ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | |
| 1000x10 | 0.2578 | 0.2578 | 49.71 | 0.08203 | 0.01172 | 0.2812 |
| 10000x10 | 0.875 | 0.875 | 52.54 | 0.8672 | 0.1523 | 3.816 |
| 100000x10 | 6.973 | 6.973 | 73.12 | 8.477 | 1.531 | 45.29 |
| 1000000x10 | 68.21 | 68.41 | 278.8 | 82 | 21.41 | 407.5 |
| 10000x100 | 5.004 | 4.922 | 73.2 | 7.074 | 0.125 | 37.96 |
| 100000x100 | 48.18 | 48.26 | 279.2 | 75.05 | 1.531 | 412.8 |
ADBench datasets
| dataset | fit, MB | score, MB | ||||
|---|---|---|---|---|---|---|
| ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | |
| 1_ALOI | 7.367 | 7.445 | 80.27 | 10.43 | 0.6055 | 61.05 |
| 2_annthyroid | 0.5547 | 0.4727 | 49.71 | 0.3594 | 0.08594 | 2.727 |
| 3_backdoor | 87.84 | 87.84 | 476.8 | 141.1 | 1.172 | 770.7 |
| 4_breastw | 0.1484 | 0.2344 | 49.61 | 0.04688 | 0.007812 | 0 |
| 5_campaign | 12.82 | 12.83 | 108 | 19.68 | 0.5039 | 116.6 |
| 6_cardio | 0.3281 | 0.3281 | 49.66 | 0.3008 | 0.01953 | 2.449 |
| 7_Cardiotocography | 0.4453 | 0.3633 | 49.89 | 0.3477 | 0.01953 | 2.719 |
| 8_celeba | 40.79 | 40.46 | 229.2 | 60.27 | 2.793 | 327.4 |
| 9_census | 692 | 691.4 | 3476 | 1142 | 4.117 | 6164 |
| 10_cover | 19.75 | 19.83 | 111.3 | 24.02 | 3.504 | 130.5 |
| 11_donors | 42.29 | 42.49 | 192.6 | 47.97 | 8.684 | 282.7 |
| 12_fault | 0.4727 | 0.4727 | 49.81 | 0.4102 | 0.02344 | 3.023 |
| 13_fraud | 44.1 | 44.34 | 239.9 | 63.1 | 3.918 | 338.6 |
| 14_glass | 0.1172 | 0.1172 | 49.48 | 0.01562 | 0.003906 | 0 |
| 15_Hepatitis | 0.1172 | 0.1992 | 49.55 | 0.01562 | 0 | 0 |
| 16_http | 20.97 | 20.97 | 83.07 | 15.61 | 6.949 | 75.1 |
| 17_InternetAds | 14.26 | 14.26 | 120.1 | 23.36 | 0.02344 | 116.6 |
| 18_Ionosphere | 0.168 | 0.25 | 49.44 | 0.08594 | 0.003906 | 0.457 |
| 19_landsat | 1.316 | 1.398 | 51.89 | 1.797 | 0.07812 | 8.836 |
| 20_letter | 0.3828 | 0.4648 | 50.04 | 0.3984 | 0.01953 | 2.969 |
| 21_Lymphography | 0.1992 | 0.1992 | 49.5 | 0.02734 | 0.003906 | 0 |
| 22_magic.gamma | 1.414 | 1.496 | 51.81 | 1.594 | 0.2266 | 8.582 |
| 23_mammography | 0.7539 | 0.668 | 50.82 | 0.5625 | 0.1367 | 3.074 |
| 24_mnist | 3.766 | 3.848 | 67.39 | 5.836 | 0.08984 | 28.83 |
| 25_musk | 2.598 | 2.602 | 61.83 | 3.891 | 0.03125 | 19.04 |
| 26_optdigits | 1.758 | 1.762 | 57.71 | 2.57 | 0.05859 | 12.25 |
| 27_PageBlocks | 0.4805 | 0.4766 | 49.77 | 0.4492 | 0.0625 | 3.094 |
| 28_pendigits | 0.8516 | 0.7656 | 51.12 | 0.8711 | 0.08203 | 4.195 |
| 29_Pima | 0.2383 | 0.2383 | 49.53 | 0.04688 | 0.007812 | 0.03125 |
| 30_satellite | 1.398 | 1.316 | 53.54 | 1.797 | 0.07812 | 10.53 |
| 31_satimage-2 | 1.199 | 1.281 | 51.86 | 1.617 | 0.06641 | 7.969 |
| 32_shuttle | 3.336 | 3.258 | 58.52 | 3.598 | 0.6016 | 19.95 |
| 33_skin | 9.164 | 9.078 | 65.36 | 6.738 | 2.996 | 32.45 |
| 34_smtp | 3.672 | 3.59 | 55.73 | 2.617 | 1.164 | 12.26 |
| 35_SpamBase | 1.391 | 1.391 | 52.06 | 1.848 | 0.05078 | 9.105 |
| 36_speech | 6.969 | 6.973 | 83.93 | 11.27 | 0.04297 | 56.14 |
| 37_Stamps | 0.1328 | 0.1289 | 49.41 | 0.02344 | 0.003906 | 0.0625 |
| 38_thyroid | 0.3828 | 0.3828 | 49.55 | 0.1836 | 0.04297 | 0.9727 |
| 39_vertebral | 0.1172 | 0.1953 | 49.43 | 0.01562 | 0.003906 | 0 |
| 40_vowels | 0.3047 | 0.2188 | 49.38 | 0.1406 | 0.01172 | 0.7891 |
| 41_Waveform | 0.6016 | 0.5195 | 50.8 | 0.5664 | 0.03516 | 2.758 |
| 42_WBC | 0.1172 | 0.2031 | 49.5 | 0.01562 | 0.003906 | 0 |
| 43_WDBC | 0.2539 | 0.1719 | 49.36 | 0.08594 | 0.003906 | 0.4492 |
| 44_Wilt | 0.4141 | 0.3281 | 49.42 | 0.2031 | 0.05469 | 1.039 |
| 45_wine | 0.1133 | 0.1992 | 49.56 | 0.01562 | 0.003906 | 0 |
| 46_WPBC | 0.2188 | 0.1406 | 49.5 | 0.05469 | 0.003906 | 0 |
| 47_yeast | 0.2773 | 0.1992 | 49.52 | 0.08984 | 0.01562 | 0.4414 |
Saving and loading
| dataset | variant | save, s | load, s | file, MB | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | ||
| 1000x10 | default | 0.0001355 (3.9x) | 0.0001396 (3.8x) | 0.0005243 | 0.0001317 (2.7x) | 0.0001415 (2.5x) | 0.0003526 | 0.04396 | 0.04397 | 0.2389 |
| 1000x10 | compressed | 0.001814 (2.7x) | 0.001866 (2.7x) | 0.00497 | 0.0001383 (11.4x) | 0.0001378 (11.5x) | 0.00158 | 0.04394 | 0.04395 | 0.09782 |
| 10000x10 | default | 0.0008743 (1.8x) | 0.0009051 (1.7x) | 0.001537 | 0.0005385 (1.5x) | 0.0005146 (1.6x) | 0.0008159 | 0.4356 | 0.4356 | 2.381 |
| 10000x10 | compressed | 0.02267 (3.4x) | 0.02071 (3.7x) | 0.07676 | 0.000642 (24.7x) | 0.0006158 (25.8x) | 0.01589 | 0.4279 | 0.4272 | 1.633 |
| 100000x10 | default | 0.0135 (0.8x) | 0.0131 (0.8x) | 0.01083 | 0.005061 (1.8x) | 0.004639 (1.9x) | 0.008907 | 4.179 | 4.179 | 23.8 |
| 100000x10 | compressed | 0.621 (1.7x) | 0.6344 (1.7x) | 1.053 | 0.007224 (24.6x) | 0.007058 (25.1x) | 0.1775 | 3.731 | 3.731 | 21.61 |
| 1000000x10 | default | 0.1494 (0.8x) | 0.1502 (0.8x) | 0.1194 | 0.09162 (0.5x) | 0.09013 (0.5x) | 0.04246 | 40.61 | 40.61 | 238 |
| 1000000x10 | compressed | 10.91 (1.0x) | 10.87 (1.0x) | 10.63 | 0.09703 (18.1x) | 0.09664 (18.2x) | 1.758 | 30.64 | 30.64 | 223 |
| 10000x100 | default | 0.01238 (0.9x) | 0.01262 (0.9x) | 0.01086 | 0.004823 (1.7x) | 0.004753 (1.7x) | 0.008184 | 4.323 | 4.323 | 22.98 |
| 10000x100 | compressed | 0.5138 (1.4x) | 0.5251 (1.4x) | 0.721 | 0.005453 (28.2x) | 0.005203 (29.6x) | 0.1537 | 4.281 | 4.281 | 15.65 |
| 100000x100 | default | 0.1611 (0.9x) | 0.1607 (0.9x) | 0.1452 | 0.09305 (0.5x) | 0.09303 (0.5x) | 0.0442 | 41.71 | 41.71 | 229.8 |
| 100000x100 | compressed | 10.51 (1.0x) | 10.46 (1.0x) | 10.05 | 0.1175 (14.6x) | 0.1177 (14.6x) | 1.714 | 37.31 | 37.31 | 211.4 |
Parallelism
Every library on all 16 cores: n_jobs=0 in ecod-rs, n_jobs=-1 in PyOD. Median time in seconds, in brackets how many times faster than the same library on one thread. Scores do not depend on the thread count.
| dataset | fit, s | score, s | pipeline, s | ||||||
|---|---|---|---|---|---|---|---|---|---|
| ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | ECOD | InductiveECOD | pyod-ECOD | |
| 1000x10 | 0.0007993 (0.7x) | 0.0007854 (0.7x) | 0.01284 (0.1x) | 0.0003845 (1.1x) | 0.0002835 (1.0x) | 0.01272 (0.1x) | 0.001121 (0.9x) | 0.001039 (0.8x) | 0.02563 (0.1x) |
| 10000x10 | 0.001744 (2.2x) | 0.001913 (1.8x) | 0.01669 (0.5x) | 0.001355 (2.2x) | 0.001076 (1.9x) | 0.01817 (0.8x) | 0.002786 (2.2x) | 0.002535 (1.9x) | 0.03453 (0.7x) |
| 100000x10 | 0.007369 (4.8x) | 0.007774 (4.7x) | 0.06714 (1.6x) | 0.004925 (6.1x) | 0.002927 (5.4x) | 0.1022 (1.8x) | 0.01286 (5.2x) | 0.0104 (5.0x) | 0.1731 (1.7x) |
| 1000000x10 | 0.09221 (4.5x) | 0.09768 (4.2x) | 0.7689 (2.0x) | 0.06469 (4.9x) | 0.03848 (4.6x) | 1.345 (1.9x) | 0.1638 (4.6x) | 0.133 (4.4x) | 2.091 (1.9x) |
| 10000x100 | 0.005323 (5.8x) | 0.005325 (5.6x) | 0.06085 (1.4x) | 0.003857 (7.3x) | 0.002779 (5.1x) | 0.09493 (1.5x) | 0.008996 (6.6x) | 0.00778 (5.6x) | 0.1559 (1.5x) |
| 100000x100 | 0.05691 (6.2x) | 0.05779 (5.8x) | 0.5902 (2.1x) | 0.05401 (5.6x) | 0.02512 (6.2x) | 1.042 (2.1x) | 0.1226 (5.3x) | 0.08547 (5.8x) | 1.65 (2.1x) |
Quality
ROC AUC on the ADBench test part.
| dataset | ROC AUC | ||
|---|---|---|---|
| ECOD | InductiveECOD | pyod-ECOD | |
| 1_ALOI | 0.5264 | 0.5262 | 0.5264 |
| 2_annthyroid | 0.757 | 0.7542 | 0.757 |
| 3_backdoor | 0.8482 | 0.8486 | 0.8482 |
| 4_breastw | 0.9929 | 0.992 | 0.9929 |
| 5_campaign | 0.7653 | 0.7652 | 0.7653 |
| 6_cardio | 0.9291 | 0.927 | 0.9291 |
| 7_Cardiotocography | 0.7836 | 0.7853 | 0.7836 |
| 8_celeba | 0.7485 | 0.7486 | 0.7485 |
| 9_census | 0.6603 | 0.6608 | 0.6603 |
| 10_cover | 0.9238 | 0.9234 | 0.9238 |
| 11_donors | 0.8884 | 0.8879 | 0.8884 |
| 12_fault | 0.4975 | 0.5001 | 0.4975 |
| 13_fraud | 0.9464 | 0.9464 | 0.9464 |
| 14_glass | 0.7871 | 0.7871 | 0.7871 |
| 15_Hepatitis | 0.7714 | 0.7886 | 0.7714 |
| 16_http | 0.9787 | 0.9786 | 0.9787 |
| 17_InternetAds | 0.6833 | 0.685 | 0.6833 |
| 18_Ionosphere | 0.7336 | 0.7354 | 0.7336 |
| 19_landsat | 0.3826 | 0.3853 | 0.3826 |
| 20_letter | 0.5206 | 0.5138 | 0.5206 |
| 21_Lymphography | 1 | 1 | 1 |
| 22_magic.gamma | 0.635 | 0.634 | 0.635 |
| 23_mammography | 0.9288 | 0.9295 | 0.9288 |
| 24_mnist | 0.7422 | 0.7391 | 0.7422 |
| 25_musk | 0.9492 | 0.9445 | 0.9492 |
| 26_optdigits | 0.5938 | 0.5985 | 0.5938 |
| 27_PageBlocks | 0.9116 | 0.9093 | 0.9116 |
| 28_pendigits | 0.9287 | 0.9301 | 0.9287 |
| 29_Pima | 0.6084 | 0.6042 | 0.6084 |
| 30_satellite | 0.5945 | 0.5966 | 0.5945 |
| 31_satimage-2 | 0.9636 | 0.9636 | 0.9636 |
| 32_shuttle | 0.9937 | 0.9938 | 0.9937 |
| 33_skin | 0.4885 | 0.4892 | 0.4885 |
| 34_smtp | 0.9536 | 0.9535 | 0.9536 |
| 35_SpamBase | 0.673 | 0.6793 | 0.673 |
| 36_speech | 0.4481 | 0.4493 | 0.4481 |
| 37_Stamps | 0.8782 | 0.8776 | 0.8782 |
| 38_thyroid | 0.9775 | 0.9772 | 0.9775 |
| 39_vertebral | 0.2827 | 0.2768 | 0.2827 |
| 40_vowels | 0.5643 | 0.5507 | 0.5643 |
| 41_Waveform | 0.6288 | 0.6281 | 0.6288 |
| 42_WBC | 0.9923 | 0.9923 | 0.9923 |
| 43_WDBC | 0.9598 | 0.951 | 0.9598 |
| 44_Wilt | 0.4018 | 0.3979 | 0.4018 |
| 45_wine | 0.43 | 0.4 | 0.43 |
| 46_WPBC | 0.44 | 0.4238 | 0.44 |
| 47_yeast | 0.4335 | 0.4327 | 0.4335 |