Metadata-Version: 2.4
Name: driftguard-prathvi
Version: 0.1.0
Summary: A robust data drift detection and schema validation library for machine learning pipelines.
Author-email: DriftGuard Developer <developer@driftguard.org>
License: MIT
Project-URL: Homepage, https://github.com/developer/driftguard
Project-URL: Documentation, https://github.com/developer/driftguard#readme
Project-URL: Bug-Tracker, https://github.com/developer/driftguard/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.18.0
Requires-Dist: pandas>=1.0.0
Requires-Dist: scipy>=1.5.0
Dynamic: license-file

# 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.
- **Severity Tagging**: Categorizes issues as `INFO`, `WARNING`, or `CRITICAL` for 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

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

```python
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](LICENSE) file for details.
