Metadata-Version: 2.4
Name: checkdrift
Version: 1.0.0
Summary: One-line drift detection for ML APIs. Like Pydantic or a rate limiter, but for data drift.
Project-URL: Homepage, https://github.com/valdanylchuk/driftdetect
Project-URL: Repository, https://github.com/valdanylchuk/driftdetect
Project-URL: Issues, https://github.com/valdanylchuk/driftdetect/issues
Author-email: Valentyn Danylchuk <val@danylchuk.com>
License-Expression: MIT
License-File: LICENSE
Keywords: drift-detection,fastapi,machine-learning,mlops,monitoring
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: numpy>=1.21.0
Requires-Dist: scipy>=1.7.0
Provides-Extra: dev
Requires-Dist: fastapi>=0.100.0; extra == 'dev'
Requires-Dist: httpx>=0.24.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# 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:

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

## Installation

```bash
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

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

See [examples/lendingclub](examples/lendingclub) for a complete example with sample data.

## Options

```python
@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
