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 6.4x 6.2x
score 12.0x 17.7x
fit + score 9.4x 10.6x

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.2.0

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.2.0
File Size Uploaded Provenance Actions
ecod_rs-1.2.0.tar.gz 77.6 kB Without provenance Details for ecod_rs-1.2.0.tar.gz

Built distributions (wheels)

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

Total release size: 6.2 MB

Release files / ecod_rs-1.2.0.tar.gz

Download URL ecod_rs-1.2.0.tar.gz
Size 77.6 kB
Tags Source
SHA-256 checksum
How to use checksums
519edc4a3e99ee6c8eac270dc3a012a2b2df296cf6ff336ba64176c5887649fa
BLAKE2b-256 checksum
How to use checksums
4baa3568808658c303da50ff68d29ff0ad1e4c964e640f9ed06d5027ed79ed13
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.2.0-cp312-abi3-win_arm64.whl

Download URL ecod_rs-1.2.0-cp312-abi3-win_arm64.whl
Size 486.6 kB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
e2ed8d0e037cfd5dcca5a67ea25095285347dc4cc487e4318d177d6a3410ce7c
BLAKE2b-256 checksum
How to use checksums
96d153ed9f6ecdef71a10c540d656c18fbc8d0333107a6ab2feb5ae49c2871b5
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.2.0-cp312-abi3-win_amd64.whl

Download URL ecod_rs-1.2.0-cp312-abi3-win_amd64.whl
Size 506.3 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c10a435da4ae66bab1e732e175a9ce19e573266fffd51028eb2e36f42c8d2572
BLAKE2b-256 checksum
How to use checksums
64d2dad74b1da8bc510054bb5511f3083cfd51e04c2c8c03977f360dcafa6bef
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.2.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL ecod_rs-1.2.0-cp312-abi3-musllinux_1_2_x86_64.whl
Size 1.1 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
2bf9065bbd25f38780301492f4e0a538589e01a982118542e85a5f3c2fc30407
BLAKE2b-256 checksum
How to use checksums
81170c57bbffaeb4e2e4066693e934f4651602f09f16c0a93673e727f0f9e9be
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.2.0-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL ecod_rs-1.2.0-cp312-abi3-musllinux_1_2_aarch64.whl
Size 1.0 MB
Tags CPython 3.12 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
164816a5dd2170df8adc1cbfd19c395ab2c64152ae9780f24517d889ff607509
BLAKE2b-256 checksum
How to use checksums
f8d9aacebf1687d2d095d553a7b8a08c32520210a15897ee7966fe1a2fdd5e4e
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.2.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ecod_rs-1.2.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 864.2 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
cbed3b46d7d7cb6c6c32f005d9c2c38aa6423e6af26ca53b25e9bd65e65ebbfd
BLAKE2b-256 checksum
How to use checksums
d1177547aaee7ba7f8200f107ac94ee25be3f049344eb6d993148bad83717956
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.2.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ecod_rs-1.2.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 802.3 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
889a074cb08c685e13f39f4ce66fc6699a3db6a38b41e1e2d8e7dc332fa68560
BLAKE2b-256 checksum
How to use checksums
59515b8ead67091f9b14d3eda2bf8c6ff892101eb58df04ed52d4c394c6888dd
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.2.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL ecod_rs-1.2.0-cp312-abi3-macosx_11_0_arm64.whl
Size 665.4 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c1d28d45a93d636f54a4602a39c684fd4087d0946101e38068ecc06b767d6c43
BLAKE2b-256 checksum
How to use checksums
61f719b4f8b56e8b7269507c0f43dda9d27a15203ad1613b6ba48d6b2dc427fb
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.2.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL ecod_rs-1.2.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 742.0 kB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
fb61a91f5c2aa37cfd35a427099861fa00aa0ee538b190964723bf9c511db8b3
BLAKE2b-256 checksum
How to use checksums
cddd09e2ceaf087e576751e76780791f58629aa49de71094b0cb6b87b59d2b60
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.2.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.

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