Metadata-Version: 2.4
Name: tabml-guard
Version: 0.1.3
Summary: A configuration-driven, explainable, drift-aware AutoML pipeline for time-ordered tabular data.
Author-email: Ayush Gole <ayushgole1910@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Ayush Gole and contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/Ayush-Gole8/tabml
Project-URL: Repository, https://github.com/Ayush-Gole8/tabml
Project-URL: Documentation, https://github.com/Ayush-Gole8/tabml#readme
Project-URL: Bug Tracker, https://github.com/Ayush-Gole8/tabml/issues
Keywords: automl,machine-learning,tabular,concept-drift,explainability,shap,hyperparameter-optimization,time-series
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
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: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: scipy>=1.10
Requires-Dist: pyyaml>=6.0
Requires-Dist: joblib>=1.3
Requires-Dist: scikit-learn>=1.3
Requires-Dist: xgboost>=2.0
Requires-Dist: lightgbm>=4.0
Requires-Dist: catboost>=1.2
Requires-Dist: optuna>=3.4
Requires-Dist: shap>=0.44
Requires-Dist: statsmodels>=0.14
Requires-Dist: matplotlib>=3.7
Requires-Dist: seaborn>=0.12
Requires-Dist: reportlab>=4.0
Provides-Extra: drift
Requires-Dist: river>=0.21; extra == "drift"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: mypy>=1.8; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Provides-Extra: all
Requires-Dist: tabml-guard[dev,drift]; extra == "all"
Dynamic: license-file

# TabML-Guard

[![PyPI](https://img.shields.io/pypi/v/tabml-guard?color=blue)](https://pypi.org/project/tabml-guard/)
[![Python](https://img.shields.io/badge/Python-3.10--3.12-3776AB?logo=python&logoColor=white)](https://pypi.org/project/tabml-guard/)
[![License](https://img.shields.io/badge/License-MIT-0f766e)](https://github.com/Ayush-Gole8/tabml/blob/main/LICENSE)
[![CI](https://github.com/Ayush-Gole8/tabml/actions/workflows/ci.yml/badge.svg)](https://github.com/Ayush-Gole8/tabml/actions)

**TabML-Guard** is an explainable, drift-aware AutoML and diagnostic framework designed specifically for time-ordered tabular data.

It automates the full supervised machine learning workflow—from leakage-safe preprocessing and baseline modeling to hyperparameter optimization, SHAP explainability, walk-forward drift simulation, and standalone diagnostic report generation.

---

## Key Features

- **Leakage-Safe Temporal Validation**: Preprocessors are fit strictly on training splits and re-fit within every fold. Time order is preserved to prevent look-ahead bias.
- **Model Diversity**: Trains regularized linear baselines (L1, L2, ElasticNet), gradient boosted trees (XGBoost, LightGBM, CatBoost), Random Forests, and regularized stacking meta-models.
- **Cost-Accounted HPO**: Evaluates Grid, Random, and Bayesian (Optuna TPE) optimization against default configurations under strictly matched evaluation budgets.
- **Explainability & Triage**: Computes global and local SHAP feature attributions paired with uncertainty-calibrated confidence guardrails to route high-risk predictions for human review.
- **Prequential Drift Diagnostics**: Simulates real-world streaming on held-out temporal chunks, comparing frozen vs. adaptive retraining alongside Population Stability Index (PSI) tracking and statistical significance tests (McNemar / Wilcoxon).
- **Zero-Dependency Portable Reporting**: Persists the production pipeline (`best_model.pkl`) and compiles standalone, portable HTML and PDF diagnostic audit reports.

---

## Installation

TabML-Guard requires **Python 3.10 to 3.12**.

```bash
pip install tabml-guard
```

To install with all optional accelerators (such as River for streaming drift detection):

```bash
pip install "tabml-guard[all]"
```

---

## Quickstart

### Python API

```python
import pandas as pd
from tabml_guard import TabMLGuard

# Load your tabular data
df = pd.read_csv("data.csv")

# Initialize and run the diagnostic pipeline
guard = TabMLGuard(
    target="target_column",
    time_col="timestamp",    # Set to None for non-temporal datasets
    task="auto",             # Auto-detects classification vs. regression
    output_dir="results",
)
results = guard.fit(df)

# Export standalone diagnostic audit reports
guard.save_report("report.html", fmt="html")
guard.save_report("report.pdf", fmt="pdf")

# Retrieve the fitted scikit-learn pipeline for inference
model = guard.get_best_model()
predictions = guard.predict(df.drop(columns=["target_column", "timestamp"]))
```

### Command-Line Interface (CLI)

Run TabML-Guard directly on any CSV file:

```bash
tabml-guard run --data data.csv --target target_column --time timestamp
```

Or run using a declarative YAML configuration:

```bash
tabml-guard run --config config.yaml
```

Initialize a starter configuration template in your working directory:

```bash
tabml-guard init
```

---

## Pipeline Stages

TabML-Guard executes a structured 6-stage diagnostic workflow:

| Stage | Name | Description |
|---|---|---|
| **Stage 0** | **Ingestion & Temporal Split** | Ingests data, detects task type, builds leakage-safe transformers, and splits data chronologically. |
| **Stage 1** | **Linear Baselines** | Fits regularized linear models (L1, L2, ElasticNet) and traces regularization paths. |
| **Stage 2** | **Ensembles & Stacking** | Trains boosting models (XGBoost, LightGBM, CatBoost), Random Forest, and a stacking meta-learner. |
| **Stage 3** | **Cost-Accounted HPO** | Compares Default, Grid, Random, and Bayesian search at matched evaluation budgets. |
| **Stage 4** | **Explainability & Triage** | Generates SHAP attributions and calculates confidence-calibrated human review triage curves. |
| **Stage 5** | **Concept Drift & Testing** | Evaluates walk-forward streams, tracks feature PSI over time, and runs statistical significance tests. |

---

## Important Links

- **Source Code**: [github.com/Ayush-Gole8/tabml](https://github.com/Ayush-Gole8/tabml)
- **Issue Tracker**: [github.com/Ayush-Gole8/tabml/issues](https://github.com/Ayush-Gole8/tabml/issues)
- **PyPI Releases**: [pypi.org/project/tabml-guard](https://pypi.org/project/tabml-guard/)

---

## License

TabML-Guard is open-source software released under the [MIT License](https://github.com/Ayush-Gole8/tabml/blob/main/LICENSE).
