Skip to main content

One-line drift detection for ML APIs. Like Pydantic or a rate limiter, but for data drift.

Project description

checkdrift

One-line drift detection for ML APIs. Like Pydantic or a rate limiter, but for data drift.

Just add @check_drift decorator to your FastAPI endpoint:

@app.post("/predict")
@check_drift(baseline="baseline.json")
async def predict(application: LoanApplication):
    return model.predict(application)

Installation

pip install checkdrift

What It Does

  • Maintains a sliding window of recent requests
  • Computes drift metrics every N requests (default: 50)
  • Logs warnings when drift is detected
  • Minimal impact on your endpoint response (about 1ms in my tests)

Uses PSI (Population Stability Index) and KS test - industry standards from banking.

Baseline Format

{"distributions": {"feature1": [1.0, 2.0, ...], "feature2": [...]}}

See examples/lendingclub for a complete example with sample data.

Options

@check_drift(
    baseline="baseline.json",
    window_size=100,       # Sliding window size
    check_interval=50,     # Check every N requests
    on_drift=my_callback,  # Optional callback
)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

checkdrift-1.0.0.tar.gz (108.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

checkdrift-1.0.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file checkdrift-1.0.0.tar.gz.

File metadata

  • Download URL: checkdrift-1.0.0.tar.gz
  • Upload date:
  • Size: 108.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for checkdrift-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a179722c39788bcbf7bfea08ff8d938236fe68d515a3e3eec9c8e0e22ebe4dd2
MD5 88ccf15c055aaa4044f36a49b7ad444e
BLAKE2b-256 a66995e89cf65947ecfb38334027fe94c5ebf0336c3cdbd3a433ab1773cfa1ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for checkdrift-1.0.0.tar.gz:

Publisher: publish.yml on valdanylchuk/driftdetect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file checkdrift-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: checkdrift-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for checkdrift-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 305e8aaeb445108bc5deca7135892938ee382f664306d852ca7a9f2d481afa84
MD5 743354118d7986d0f14cb849720b5208
BLAKE2b-256 4a8df3a89d1e3ce75cc595c73c66a66c97c9885a3aaca8a5fb274c22a34a1e09

See more details on using hashes here.

Provenance

The following attestation bundles were made for checkdrift-1.0.0-py3-none-any.whl:

Publisher: publish.yml on valdanylchuk/driftdetect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page