DriftGuard
DriftGuard is a lightweight, robust, and publish-ready Python library designed to automate dataset validation and detect statistical data drift in machine learning pipelines.
By comparing new incoming datasets against a trusted baseline reference dataset, DriftGuard alerts you to schema changes, increases in missing values, or shifts in feature distributions before they affect downstream model performance.
Features
- Schema Validation: Detect missing columns, new columns, and data type mismatches.
- Null Rate Analysis: Monitor and flag columns where the rate of missing values increases beyond a configurable threshold.
- Statistical Drift Detection:
- Kolmogorov-Smirnov (KS) Test (
scipy.stats.ks_2samp) for numerical columns. - Chi-Square Test (
scipy.stats.chi2_contingency) for categorical columns.
- Kolmogorov-Smirnov (KS) Test (
- Severity Tagging: Categorizes issues as
INFO,WARNING, orCRITICALfor pipeline routing or CI/CD gate checks. - Interactive Reports:
- An ASCII summary table output directly to console.
- Machine-readable JSON output for automated pipelines.
- A beautiful, self-contained interactive HTML dashboard with per-column breakdowns and interactive searching/filtering.
Installation
pip install driftguard
Note: Depends on numpy, pandas, and scipy only.
Quickstart
Validate your production features in real-time or as part of a batch training/inference pipeline:
import numpy as np
import pandas as pd
import driftguard as dg
# 1. Create a reference dataset (baseline)
np.random.seed(42)
ref_data = {
"age": np.random.normal(35, 10, 1000),
"income": np.random.uniform(30000, 120000, 1000),
"city": np.random.choice(["New York", "Chicago", "San Francisco"], 1000),
"target": np.random.choice([0, 1], 1000, p=[0.7, 0.3])
}
reference_df = pd.DataFrame(ref_data)
# 2. Create a new dataset (with some drift and schema issues)
new_data = {
"age": np.random.normal(38, 10, 1000), # Slight shift
"income": np.random.uniform(30000, 120000, 1000),
"city": np.random.choice(["New York", "Chicago", "Boston"], 1000), # "Boston" is a new category
"target": np.random.choice([0, 1], 1000, p=[0.7, 0.3]),
"extra_col": np.random.random(1000) # New column
}
new_df = pd.DataFrame(new_data)
# Add some null values to 'income'
new_df.loc[np.random.choice(1000, 150, replace=False), "income"] = np.nan
# 3. Instantiate Validator and run checks
# p_threshold matches the significance alpha for KS/Chi2
# null_threshold is the maximum allowed null rate increase
validator = dg.Validator(reference_df, p_threshold=0.05, null_threshold=0.10)
report = validator.check(new_df)
# 4. Consume the report
# Prints a formatted ASCII table of all issues
report.summary()
# Export interactive HTML dashboard (saves report.html)
report.export("html")
# Export machine-readable JSON (saves report.json)
report.export("json")
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for driftguard-prathvi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| driftguard_prathvi-0.1.0.tar.gz | 18.5 kB | Without provenance | Details for driftguard_prathvi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| driftguard_prathvi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for driftguard_prathvi-0.1.0-py3-none-any.whl |
Total release size: 36.5 kB
Release files / driftguard_prathvi-0.1.0.tar.gz
| Download URL | driftguard_prathvi-0.1.0.tar.gz |
|---|---|
| Size | 18.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bc282fbf7ad790d8a564d5d6aa799735a58a637ab235157796cacd06ef938c9
|
|
BLAKE2b-256 checksum How to use checksums |
71050be5ded92385e2501853ebe03d5f23b68be0f02f87759267099a00d4e440
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / driftguard_prathvi-0.1.0-py3-none-any.whl
| Download URL | driftguard_prathvi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3fecc05a74595e9789fddabcf42e9d1d172824e61da1401b0f2dde222b4e7150
|
|
BLAKE2b-256 checksum How to use checksums |
a74e9c34759ec8cd9541f0f02fa7bd2d4161926f944b45e082573d5a93b12391
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for driftguard-prathvi 0.1.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.