Metadata-Version: 2.4
Name: syntex-automl
Version: 0.3.2
Summary: Ultra-lightweight (<150MB) autonomous machine learning engine with automated hygiene, hybrid stacking, FastAPI interactive UI export, and drift monitoring.
Author: Badri Vishal
License: MIT
Project-URL: Homepage, https://github.com/Syntex34x/AutoML
Project-URL: Bug Tracker, https://github.com/Syntex34x/AutoML/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.22.0
Requires-Dist: pandas>=1.4.0
Requires-Dist: scipy>=1.8.0
Requires-Dist: scikit-learn>=1.1.0
Requires-Dist: xgboost>=1.6.0
Requires-Dist: optuna>=3.0.0
Requires-Dist: requests>=2.28.0
Requires-Dist: beautifulsoup4>=4.11.0
Requires-Dist: lxml>=4.9.0
Requires-Dist: joblib>=1.2.0
Dynamic: license-file

<div align="center">

# ⚡ syntex-automl

**Autonomous, Lightweight (<150MB), Zero-Config AutoML & Micro-Deployment Engine**

[![PyPI Version](https://img.shields.io/badge/pypi-v0.3.1-blue.svg)](https://pypi.org/project/syntex-automl/)
[![Python Versions](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-brightgreen.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![GitHub Repo](https://img.shields.io/badge/GitHub-Syntex34x%2FAutoML-181717.svg?logo=github)](https://github.com/Syntex34x/AutoML)
[![Package Size](https://img.shields.io/badge/size-%3C150MB-informational.svg)](#)

<p align="center">
  <a href="#-overview">Overview</a> •
  <a href="#️-architecture--pipeline-flow">Architecture</a> •
  <a href="#-features">Features</a> •
  <a href="#-installation">Installation</a> •
  <a href="#-quickstart">Quickstart</a> •
  <a href="#-production-bundle--microservice-suite">Production Suite</a> •
  <a href="#️-advanced-usage--custom-ingestion">Advanced Usage</a> •
  <a href="#-ecosystem-positioning">Benchmark</a> •
  <a href="#-api-reference">API Reference</a>
</p>

</div>

---

## 📌 Overview

**syntex-automl** is an ultra-lightweight (**<150 MB**), production-ready AutoML engine built for developers who need end-to-end model training, hybrid meta-learning, and automated web deployment — without dragging in multi-gigabyte dependency trees.

From direct HTML web-table ingestion and automated regex-based title/interaction synthesis, to Bayesian optimization across heterogeneous algorithms and hybrid stacking, **syntex-automl** completes the full modeling lifecycle in **3 lines of Python** and exports an immediately runnable microservice bundle — complete with an interactive web UI.

---

## 🏗️ Architecture & Pipeline Flow

The engine orchestrates data ingestion, tabular hygiene, Bayesian optimization, hybrid stacking, and microservice packaging autonomously:

```text
[Input: Raw CSV / Web URL / Live HTML Table]
                    │
                    ▼
  ┌─────────────────────────────────┐
  │         AutoWebIngest           │  ◄── Local Files, Remote Endpoints, Live HTML Tables
  └────────────────┬────────────────┘
                    ▼
  ┌─────────────────────────────────┐
  │         AutoDataCleaner         │  ◄── Imputation, Title/Regex Extraction, Group Interactivity,
  │   (Automated Tabular Hygiene)   │      Collinear Pruning (|r| > 0.95), High-Cardinality Filtering
  └────────────────┬────────────────┘
                    ▼
  ┌─────────────────────────────────┐
  │      Bayesian Search Loop       │  ◄── Optuna TPE Hyperparameter Search + Stratified CV
  │   (Heterogeneous Model Hunt)    │  ◄── HistGradientBoosting, XGBoost, ExtraTrees, RandomForest, MLP, KNN
  └────────────────┬────────────────┘
                    ▼
  ┌─────────────────────────────────┐
  │  Hybrid Stacking Meta-Learner   │  ◄── Stacking Meta-Learner combining top heterogeneous models
  │  (Generalization Optimization)  │
  └────────────────┬────────────────┘
                    ▼
  ┌─────────────────────────────────┐
  │  Complete Production Package    │  ◄── Exports: model.pkl, app.py (FastAPI + Web UI),
  │       (One-Click Deploy)        │      verify.py, Dockerfile, drift_monitor.py, audit_metrics.json
  └─────────────────────────────────┘
```

---

## ✨ Features

- 🌐 **Autonomous Ingestion (`AutoWebIngest`)** — Load directly from local files, remote CSV endpoints, or scrape live HTML tables from any URL.
- 🧹 **Automated Tabular Hygiene & Feature Engineering** — Extracts honorifics/titles from text, calculates interaction groups (e.g., family size), imputes missing values, and prunes collinear feature pairs.
- 🏆 **Hybrid Stacking Meta-Learner** — Trains diverse candidate models (tree ensembles, HistGradientBoosting, neural nets, regularized linear models, KNN) and automatically stacks top performers with a meta-learner.
- 🎯 **Bayesian Optimization** — Tree-structured Parzen Estimator (TPE) search with cross-validation and adaptive trial pruning.
- 🚀 **FastAPI Web UI & REST Microservice Export** — Generates `app.py`, featuring a built-in browser-based testing dashboard and a `/predict` JSON API.
- 🛡️ **Kolmogorov–Smirnov Data Drift Monitoring** — Generates `drift_monitor.py` to continuously track feature-distribution drift against the training baseline.
- 🐳 **Ready-to-Deploy Dockerfile** — Instant containerization with zero manual dependency configuration.

---

## 🚀 Installation

Install the latest release directly from PyPI:

```bash
pip install syntex-automl
```

---

## ⚡ Quickstart

### Train and Export in 3 Lines

```python
import syntex_automl as apm

# 1. Initialize engine with local file or direct URL
engine = apm.AutoEngine(
    data="https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv",
    target="Survived",
    max_trials=15
)

# 2. Run automated feature engineering, search & hybrid stacking
engine.fit()

# 3. Export complete deployment microservice
engine.download_bundle("./my_model_bundle")
```

### Sample Terminal Output

```text
[AutoPilotML] Task: CLASSIFICATION | Samples: 712 | Features: 12

==================================================
🏆 BEST MODEL SELECTED: Hybrid_Ensemble_Stack
==================================================
 ▸ Mechanism        : Stacked Meta-Learner combining predictions of top candidates: XGBoost, KNN, RandomForest
 ▸ Optimal Use-Case : Maximizing out-of-fold generalization across heterogeneous models.
 ▸ Imbalance Ratio  : 1.61:1 (Balanced Loss Configured)
--------------------------------------------------
📊 HOLDOUT VERIFICATION SCORECARD (CLASSIFICATION)
--------------------------------------------------
 ▸ Accuracy            : 0.8380
 ▸ Precision           : 0.8385
 ▸ Recall              : 0.8380
 ▸ F1 score            : 0.8382
==================================================

📦 Production package generated in './my_model_bundle/'
 ▸ Files: model.pkl, test_holdout.csv, audit_metrics.json, verify.py, app.py (FastAPI + UI), Dockerfile, drift_monitor.py
```

---

## 📦 Production Bundle & Microservice Suite

The exported directory contains a complete production service, ready for instant execution:

```text
my_model_bundle/
├── model.pkl            # Complete serialized pipeline (preprocessing + stacked model)
├── app.py               # Production FastAPI REST microservice + embedded Web UI
├── verify.py            # Standalone batch validation script
├── drift_monitor.py     # Statistical Kolmogorov-Smirnov data drift monitor
├── Dockerfile           # Standalone deployment container configuration
├── test_holdout.csv     # 20% unseen test split for auditing
└── audit_metrics.json   # Machine-readable model scorecard & feature metadata
```

### 1. Launch the Live Web Testing UI

Start the local server:

```bash
cd my_model_bundle
python app.py
```

Open **http://localhost:8000/** in your browser to interact with the model in real time.

### 2. Verify Holdout Batch Pipeline

```bash
python verify.py
```

### 3. Run Statistical Drift Detection

```bash
python drift_monitor.py
```

---

## 🛠️ Advanced Usage & Custom Ingestion

### Autonomous Web Scraping

Extract and train directly from HTML tables on live webpages — no separate scraping step required:

```python
from syntex_automl import AutoWebIngest, AutoEngine

# Ingest a table directly from a webpage
df = AutoWebIngest.fetch(
    "https://en.wikipedia.org/wiki/List_of_countries_by_GDP_(nominal)",
    table_idx=2
)

# Pass the scraped DataFrame directly to the engine
engine = AutoEngine(data=df, target="Nominal GDP", max_trials=15)
engine.fit()
```

### Serving Predictions Outside the Bundled Web UI

The exported `model.pkl` is a fully encapsulated pipeline (preprocessing + hybrid stack), so it can be loaded directly in any Python service — FastAPI, Flask, batch jobs, or notebooks — without depending on `app.py`:

```python
import joblib
import pandas as pd

# Load the encapsulated pipeline
pipeline = joblib.load("./my_model_bundle/model.pkl")

# Pass raw, uncleaned incoming data directly
new_data = pd.DataFrame({
    "Pclass": [3, 1],
    "Sex": ["female", "male"],
    "Age": [22.0, 38.0],
    "SibSp": [1, 1],
    "Parch": [0, 0],
    "Fare": [7.25, 71.28],
    "Embarked": ["S", "C"]
})

predictions = pipeline.predict(new_data)
print("Predictions:", predictions)
```

---

## 📊 Ecosystem Positioning

| Feature / Dimension | syntex-automl | PyCaret | AutoGluon | FLAML |
|---|---|---|---|---|
| **Footprint / Size** | Ultra-Lightweight (<150 MB) | Medium (~800 MB) | Heavy (~1.5 GB+) | Lightweight (~200 MB) |
| **API Philosophy** | 3-Line Zero-Config | Low-Code Interactive | Multi-Layer Stacking | Cost-Frugal Search |
| **Interactive Web UI Export** | Native Built-in (`app.py`) | No | No | No |
| **Live Web Scraping** | Native Built-in (`AutoWebIngest`) | Manual | Manual | Manual |
| **Drift Monitoring** | Native Built-in (`drift_monitor.py`) | Manual | Manual | Manual |
| **Deployment Assets** | FastAPI + Docker + Verify + Drift | Raw `.pkl` | Model Folder | Raw Object |

---

## 📖 API Reference

### `AutoEngine(data, target, max_trials=15, cv_folds=5, enable_hybrid_stack=True)`

- **`data`** (`str` | `pd.DataFrame`): Filepath, live web URL, or Pandas DataFrame.
- **`target`** (`str`): Name of the target column.
- **`max_trials`** (`int`, default=`15`): Number of Optuna Bayesian optimization trials.
- **`cv_folds`** (`int`, default=`5`): Cross-validation splits.
- **`enable_hybrid_stack`** (`bool`, default=`True`): Combines top candidate models into a Stacking Meta-Learner.

### Methods

- **`.fit()`** — Executes data hygiene, feature extraction, cross-validation search, model stacking, and holdout auditing.
- **`.print_diagnostics()`** — Prints the holdout verification scorecard and top predictor features.
- **`.download_bundle(folder="./my_model_bundle")`** — Generates all microservice deployment files.

---

## 📄 License

This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.

---

## 👤 Author

**Badri Vishal**

- GitHub: [@Syntex34x](https://github.com/Syntex34x)
- Repository: [AutoML](https://github.com/Syntex34x/AutoML)

---

<div align="center">

Licensed under the [MIT License](https://opensource.org/licenses/MIT)

</div>
