Metadata-Version: 2.4
Name: autocure
Version: 1.3.0
Summary: Automated data health diagnosis, smart cleaning, AutoML, and MLflow model versioning engine.
Home-page: https://github.com/Vishal2053/Autocure
Author: Vishal More
Author-email: vishalbhagwanmore12@gmail.com
License: MIT
Project-URL: Homepage, https://github.com/Vishal2053/Autocure
Project-URL: Source, https://github.com/Vishal2053/Autocure
Project-URL: Tracker, https://github.com/Vishal2053/Autocure/issues
Keywords: data-cleaning,data-science,automl,machine-learning,scikit-learn,explainability,fastapi,mlflow,model-registry
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: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: scikit-learn
Requires-Dist: click
Requires-Dist: mlflow
Provides-Extra: api
Requires-Dist: fastapi; extra == "api"
Requires-Dist: uvicorn; extra == "api"
Provides-Extra: nlp
Requires-Dist: nltk; extra == "nlp"
Provides-Extra: all
Requires-Dist: fastapi; extra == "all"
Requires-Dist: uvicorn; extra == "all"
Requires-Dist: nltk; extra == "all"
Dynamic: license-file

# Autocure

**The All-In-One Automated Data Quality, Diagnosis, AutoML & Model Versioning Engine.**

Autocure transforms raw, messy data into production-ready, explainable machine learning models in a single command, complete with **automated MLflow experiment tracking, model versioning, and an interactive dashboard**.

---

## Key Features

- **Flagship 1-Click Autopilot (`ac.autopilot(df, target)`)**
  - Instant end-to-end data science in one line: runs deep diagnosis, auto-drops non-predictive ID & constant columns, performs smart cleaning & outlier Winsorization, trains and tunes multiple ML models, and extracts feature drivers.
- **MLflow Tracking & Model Versioning**
  - **Zero-overhead design**: Tracking runs **automatically in CLI commands** (`train-model`, `run-autopilot`) to track parameters, dataset shapes, metric leaderboards, and registered model versions (`Version 1`, `Version 2`, etc.).
  - Normal Python code (`ac.train`, `ac.autopilot`) runs cleanly without overhead or file clutter unless explicitly enabled (`track_mlflow=True`).
- **Interactive MLflow Dashboard (`autocure dashboard` / `autocure ui`)**
  - Launch an interactive web dashboard with 1 command at `http://127.0.0.1:5000` to inspect runs, compare metric curves, view artifacts, and audit model versions.
- **Data Health & Leakage Doctor (`ac.diagnose(df, target)`)**
  - Calculates an overall **Data Health Score (0–100%)**.
  - Flags **Target Leakage** ($r \ge 0.95$ with target).
  - Detects **ID & High-Cardinality traps** that cause overfitting.
  - Warns about **Zero-variance constant columns** and **Severe Class Imbalance**.
- **Smart Data Curing (`ac.cure(df)`)**
  - Robust numeric imputation across all numeric dtypes.
  - Context-aware categorical cleaning that preserves standard categories while cleaning free-text NLP columns.
  - Optional statistical outlier Winsorization (`clip_outliers=True`).
- **Model Explainability & Drivers (`ac.explain(result)`)**
  - Extracts feature importances and coefficients directly into a percentage contribution table and visual driver summary.
- **Instant REST API (`ac.serve(result)`)**
  - Spins up a live FastAPI web server with interactive Swagger documentation at `/docs` in one command.
- **Production-Ready Pipeline & AutoML (`ac.train(df, target)`)**
  - Fast modern estimators including **HistGradientBoosting**, **RandomForest**, and linear models with cross-validated parameter tuning.
  - Full preprocessing pipeline bundled with model pickle for seamless deployment.

---

## Installation

From project root (editable install for development):

```bash
python -m pip install -e .
```

Or install from `requirements.txt`:

```bash
pip install -r requirements.txt
pip install nltk
```

---

## CLI Reference

Autocure comes with a rich CLI interface. CLI training commands automatically track runs and version models in MLflow.

### Available Commands

| Command | Description |
| :--- | :--- |
| `autocure dashboard` (alias `ui`) | Launch interactive MLflow dashboard server and open browser |
| `autocure train-model <file>` | Run AutoML model search with automatic MLflow versioning |
| `autocure run-autopilot <file>` | 1-Click end-to-end diagnosis, cure, AutoML & MLflow tracking |
| `autocure health <file>` | Diagnose dataset quality, health score, and data leakage |
| `autocure scan-data <file>` | Scan dataset for missing values, dtypes, and IQR outliers |
| `autocure fix <file>` | Clean dataset with smart imputation and text normalization |
| `autocure start-server <file>` | Launch production FastAPI REST service for a trained pickle |

### CLI Examples

#### 1. Train AutoML with Automatic MLflow Model Versioning
```bash
autocure train-model dataset.csv --target label
```
Output:
```text
Best Model: random_forest_classifier | Score: 0.9850
[MLflow] Tracking active: Experiment 'autocure'
[MLflow] Run ID: 703ad8884f764fc0a4bb1c10af728f60
[MLflow] Registered Model 'autocure_label' -> Version 2
[MLflow] Run `autocure dashboard` to view your models and runs.
```

#### 2. End-to-End Autopilot via CLI
```bash
autocure run-autopilot dataset.csv --target label
```

#### 3. Open MLflow Dashboard UI
```bash
# Launch dashboard and automatically open your default browser:
autocure dashboard

# Or use the shortcut alias:
autocure ui

# Custom port or host:
autocure dashboard --port 5005 --host 0.0.0.0
```

#### 4. Automatic Dashboard Launch After Training
```bash
autocure train-model dataset.csv --target label --open-dashboard
```

#### 5. Disable MLflow in CLI (Optional)
```bash
autocure train-model dataset.csv --target label --no-mlflow
```

---

## Python API Usage

### 1. Flagship Autopilot (Recommended)

```python
import autocure as ac
import pandas as pd

df = pd.read_csv("your_dataset.csv")

# 1-Line end-to-end diagnosis, auto-cleaning, AutoML, and explainability
result = ac.autopilot(df, target="target_column")

print(f"Best Model: {result.best_model_name} (Score: {result.best_score:.4f})")

# Direct inference (automatically handles preprocessing & dropped traps)
preds = result.predict(df.iloc[:5])
probs = result.predict_proba(df.iloc[:5])

# Explain top model drivers
drivers_df = result.explain(top_n=5)
```

### 2. Manual Diagnostics & Curing

```python
import autocure as ac
import pandas as pd

df = pd.read_csv("your_dataset.csv")

# Diagnose health and target leakage
report = ac.diagnose(df, target="target_column")
print("Health Score:", report["health_score"])

# Clean & cure dataset
clean_df = ac.cure(df, clip_outliers=True)

# Train AutoML models
train_res = ac.train(clean_df, target="target_column")
```

### 3. Optional MLflow Tracking in Python Code

Normal Python execution does not trigger MLflow runs to keep your scripts fast and clean. If you want MLflow tracking in Python, pass `track_mlflow=True`:

```python
train_res = ac.train(
    clean_df,
    target="target_column",
    track_mlflow=True,
    experiment_name="production_models"
)

# Open MLflow dashboard directly from Python:
ac.dashboard(port=5000)
```

---

## Serving Models as a REST API

Deploy your trained model with interactive Swagger docs in one command:

```bash
autocure start-server models/random_forest_classifier_model.pickle --port 8000
```
Visit `http://localhost:8000/docs` in your browser to interact with the API.

---

## License

MIT License. Contributions and PRs welcome!
