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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a179722c39788bcbf7bfea08ff8d938236fe68d515a3e3eec9c8e0e22ebe4dd2
|
|
| MD5 |
88ccf15c055aaa4044f36a49b7ad444e
|
|
| BLAKE2b-256 |
a66995e89cf65947ecfb38334027fe94c5ebf0336c3cdbd3a433ab1773cfa1ae
|
Provenance
The following attestation bundles were made for checkdrift-1.0.0.tar.gz:
Publisher:
publish.yml on valdanylchuk/driftdetect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
checkdrift-1.0.0.tar.gz -
Subject digest:
a179722c39788bcbf7bfea08ff8d938236fe68d515a3e3eec9c8e0e22ebe4dd2 - Sigstore transparency entry: 924290453
- Sigstore integration time:
-
Permalink:
valdanylchuk/driftdetect@1bd76ec435e74bc474700debf529bfbe1e9483d9 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/valdanylchuk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1bd76ec435e74bc474700debf529bfbe1e9483d9 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
305e8aaeb445108bc5deca7135892938ee382f664306d852ca7a9f2d481afa84
|
|
| MD5 |
743354118d7986d0f14cb849720b5208
|
|
| BLAKE2b-256 |
4a8df3a89d1e3ce75cc595c73c66a66c97c9885a3aaca8a5fb274c22a34a1e09
|
Provenance
The following attestation bundles were made for checkdrift-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on valdanylchuk/driftdetect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
checkdrift-1.0.0-py3-none-any.whl -
Subject digest:
305e8aaeb445108bc5deca7135892938ee382f664306d852ca7a9f2d481afa84 - Sigstore transparency entry: 924290459
- Sigstore integration time:
-
Permalink:
valdanylchuk/driftdetect@1bd76ec435e74bc474700debf529bfbe1e9483d9 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/valdanylchuk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1bd76ec435e74bc474700debf529bfbe1e9483d9 -
Trigger Event:
release
-
Statement type: