Skip to main content

ecod-rs

The ECOD outlier detector (Li et al., 2022) in Rust, with Python bindings.

Why

The goal is ECOD with a normal API, which PyOD doesn't have.

In PyOD, fit only stores the training data, and decision_function concatenates it with the new samples and recomputes everything. So the score of a sample depends on the rest of the batch you pass in. This was reported in #401 and #426. Yue Zhao, PyOD's maintainer and an ECOD co-author, answered that this is intended, since outlier detection is transductive. Nothing has changed since.

Here you get both:

  • InductiveECOD fits the per-feature ECDFs once and scores each sample independently.
  • ECOD behaves like PyOD.

Install

Requires Python 3.12+:

pip install ecod-rs

Usage

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)       # shape (n, 2): [inlier, outlier]

model.save("model.bin")
model = InductiveECOD.load("model.bin")

ECOD has the same interface. Input is a numpy array or a list of lists.

The method argument sets the scoring: "max" (default) follows the paper, "pyod-max" reproduces PyOD's numbers, "left", "right" and "auto" use a single tail. predict_proba takes "linear" or "unify", as in PyOD.

Benchmark

Median speedup over PyOD's ECOD on random data and 47 ADBench datasets, single-threaded:

ECOD InductiveECOD
fit 2.7x 2.7x
score 5.9x 7.5x
fit + score 4.3x 4.7x

Full results are at nedeadinside.github.io/ecod-rs. To rerun: uv run --group bench python benchmark/bench.py.

Development

uv sync
uv run pytest
cargo test

License

MIT

Metadata

Release files for ecod-rs 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ecod-rs 1.0.1
File Size Uploaded Provenance Actions
ecod_rs-1.0.1.tar.gz 74.7 kB Without provenance Details for ecod_rs-1.0.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ecod-rs 1.0.1
File Actions
ecod_rs-1.0.1-cp312-abi3-win_arm64.whl CPython 3.12 abi3 Windows ARM64 Details for ecod_rs-1.0.1-cp312-abi3-win_arm64.whl
ecod_rs-1.0.1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for ecod_rs-1.0.1-cp312-abi3-win_amd64.whl
ecod_rs-1.0.1-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for ecod_rs-1.0.1-cp312-abi3-musllinux_1_2_x86_64.whl
ecod_rs-1.0.1-cp312-abi3-musllinux_1_2_aarch64.whl CPython 3.12 abi3 Linux musl 1.2+ ARM64 Details for ecod_rs-1.0.1-cp312-abi3-musllinux_1_2_aarch64.whl
ecod_rs-1.0.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for ecod_rs-1.0.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
ecod_rs-1.0.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for ecod_rs-1.0.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
ecod_rs-1.0.1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for ecod_rs-1.0.1-cp312-abi3-macosx_11_0_arm64.whl
ecod_rs-1.0.1-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for ecod_rs-1.0.1-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 5.4 MB

Release files / ecod_rs-1.0.1.tar.gz

Download URL ecod_rs-1.0.1.tar.gz
Size 74.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2c9c15dfca51b311b1f9013e7dcb872451a2224ccc318ea2060c85a1c38fb263
BLAKE2b-256 checksum
How to use checksums
248cc5f865382f41887a3738a8aa2cd5a1c904eb2b4fe5e4e37befe7d6b2aff3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ecod_rs-1.0.1-cp312-abi3-win_arm64.whl

Download URL ecod_rs-1.0.1-cp312-abi3-win_arm64.whl
Size 414.3 kB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
b1b375b0dbc34c1e97fac670f3445e9fa663924ebf778531a5813173eb7d47c4
BLAKE2b-256 checksum
How to use checksums
f285d226cdbdea13f00970efa1c380b6c479df641818eba54d58440c025dc5ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ecod_rs-1.0.1-cp312-abi3-win_amd64.whl

Download URL ecod_rs-1.0.1-cp312-abi3-win_amd64.whl
Size 425.0 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c78809d5910e72c6ea5ddd1718fe7ab2e8e32ada0585f2138ecc0556325e68c8
BLAKE2b-256 checksum
How to use checksums
d744dd7fb24c8667b78f582bd352846006960f66d05d7871d080232be70e4d31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ecod_rs-1.0.1-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL ecod_rs-1.0.1-cp312-abi3-musllinux_1_2_x86_64.whl
Size 961.5 kB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
533ba983507421cb79c7c35aee80c5a7f9dfd458e8f7a8393ababef422f4fd47
BLAKE2b-256 checksum
How to use checksums
363cf32fb8471651df13f4f7400c2592497052979b2ed74718088a36e0f65e49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ecod_rs-1.0.1-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL ecod_rs-1.0.1-cp312-abi3-musllinux_1_2_aarch64.whl
Size 901.0 kB
Tags CPython 3.12 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
ea97625b1ea4099297a8ba371102fbeb5ef877bd5319233f9f4491be7833871a
BLAKE2b-256 checksum
How to use checksums
d5de2a009be3caf02143e5576103215603efe43679e150fdc1b4b2f481eb77cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ecod_rs-1.0.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ecod_rs-1.0.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 754.1 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
ea928fc7fc38bee550026120ea05a0fd222566c3ac0b918f2748bbc3612d511d
BLAKE2b-256 checksum
How to use checksums
c867074806c2379f99e9dbaa9b42eca4455a56a2891c9ff18efee0b6797fd38e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ecod_rs-1.0.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ecod_rs-1.0.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 692.2 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5423df7932c985ec42a66742a68eb84ea9f58c3ef27bdcd1734c7c785c8696ea
BLAKE2b-256 checksum
How to use checksums
5b4883d10ae863ae07ecf3044911ba2aee6d3aec11a6f08b5eff386fe048f674
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ecod_rs-1.0.1-cp312-abi3-macosx_11_0_arm64.whl

Download URL ecod_rs-1.0.1-cp312-abi3-macosx_11_0_arm64.whl
Size 574.8 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e143854ab81b985ae8dcd92999cdfa2cd815d31ac8ea7e6a5b7dcf2724f68916
BLAKE2b-256 checksum
How to use checksums
0e5db9ef1498798d336066d4d5913213e3a0cd84000c117ec8ed080f808c188b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ecod_rs-1.0.1-cp312-abi3-macosx_10_12_x86_64.whl

Download URL ecod_rs-1.0.1-cp312-abi3-macosx_10_12_x86_64.whl
Size 645.7 kB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
090231b27dd3aefa6aaed87fbffe2bceb41e26ba21137e443330b0f1831ddaf2
BLAKE2b-256 checksum
How to use checksums
5bf72d8200307253025b475c77f6d945eb6513e09d5f4c1d6d63c2b98b252802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ecod-rs 1.0.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page