Model Pipeline (oxigen-pipeline)
Pipeline de ML para regresión tabular orientado a calidad de aire (AQI) u otras variables continuas. Incluye: ingesta → limpieza → split → entrenamiento (con tuning) → evaluación → reporte HTML (métricas + SHAP en base64) → diagrama del pipeline.
Repo:
Danval-003/model_pipeline. ([GitHub][1])
Características
-
CLI simple para correr el pipeline sobre un
.csv. -
Preprocesamiento embebido con
ColumnTransformer:StandardScalerpara numéricas.OneHotEncoder(handle_unknown="ignore")(salida densa) para categóricas.
-
Modelos de regresión compatibles: RandomForest, Gradient Boosting, XGBoost, LightGBM.
-
Tuning con
RandomizedSearchCV(cv=3). -
SHAP con background consistente y gráfico embebido en base64 dentro del HTML.
-
Diagrama del pipeline en
pipeline_diagram.html.
Instalación
pip install -U oxigen-pipeline
Alternativa:
pip install -U --no-cache-dir oxigen-pipeline
Uso (CLI)
oxigen-pipeline --data-path final_dataset.csv --target AQI
--data-path: ruta al CSV.--target: nombre de la columna objetivo (ej.AQI).
El comando imprime métricas y genera:
model_report.html(métricas de test + gráfico SHAP embebido en base64).pipeline_diagram.html(diagrama del pipeline).
Si tu versión incluye selector de modelo por CLI, podés pasar
--model RandomForest|GBM|XGBoost|LightGBM. Si no, podés elegir el modelo vía API (ver abajo).
Datos de ejemplo
El pipeline asume un CSV con columnas numéricas y/o categóricas y una target continua. Ejemplo típico (AQI):
Date,Month,Year,Holidays_Count,Days,PM2.5,PM10,NO2,SO2,CO,Ozone,AQI
15.0,5.0,2022,1,7,118.54,257.73,3.57,24.06,1.24,33.43,295.0
...
Uso (API en Python)
import pandas as pd
from sklearn.model_selection import train_test_split
from oxigen_pipeline.model import train_and_evaluate_model
df = pd.read_csv("final_dataset.csv")
target = "AQI"
X = df.drop(columns=[target])
y = df[target]
# split train/val/test (ejemplo simple 60/20/20)
X_train, X_tmp, y_train, y_tmp = train_test_split(X, y, test_size=0.40, random_state=42)
X_val, X_test, y_val, y_test = train_test_split(X_tmp, y_tmp, test_size=0.50, random_state=42)
best_model, best_params, metrics = train_and_evaluate_model(
X_train, X_val, X_test, y_train, y_val, y_test,
html_output_path="model_report.html",
model_name="RandomForest" # "GBM" | "XGBoost" | "LightGBM"
)
print(best_params, metrics)
¿Qué hace internamente?
-
Detecta tipos: numéricas (
np.number) y categóricas (object/category). -
Arma
ColumnTransformer(num=StandardScaler, cat=OneHotEncoder(handle_unknown="ignore", salida densa)). -
Pipeline:
pre→model. -
Tuning con
RandomizedSearchCVy selección por R² de validación. -
Evalúa en test y arma
model_report.htmlcon:- MSE, MAE, R².
- SHAP summary embebido en base64 (para que siempre se vea, sin archivos extra).
-
Exporta también
pipeline_diagram.html.
Requisitos
-
Python
>=3.10 -
Dependencias principales (se instalan con el paquete):
pandas,numpy,scikit-learn,matplotlib,shap,xgboost,lightgbm,joblib.
Desarrollo
git clone https://github.com/Danval-003/model_pipeline.git
cd model_pipeline
python -m venv .venv && .\.venv\Scripts\activate
pip install -U pip build
pip install -e . # modo editable
Build y publicación:
python -m build
# subir con twine (o workflow de GitHub Actions)
Metadata
Release files for oxigen-pipeline 1.5.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 |
|---|---|---|---|---|
| oxigen_pipeline-1.5.0.tar.gz | 10.1 kB | Without provenance | Details for oxigen_pipeline-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oxigen_pipeline-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for oxigen_pipeline-1.5.0-py3-none-any.whl |
Total release size: 20.5 kB
Release files / oxigen_pipeline-1.5.0.tar.gz
| Download URL | oxigen_pipeline-1.5.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd101833fe5636defd63d59cf557ccbb914bce19856dfe5223703bf782ce5a20
|
|
BLAKE2b-256 checksum How to use checksums |
273b734021b030f34e7d8266d353ec3e10b7fb4825adea5b9b7c98c61b87374d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.10
|
Release files / oxigen_pipeline-1.5.0-py3-none-any.whl
| Download URL | oxigen_pipeline-1.5.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46355479052906ce41823a33ee7b9b927d8bff53c85f665cdd4082c57102bc74
|
|
BLAKE2b-256 checksum How to use checksums |
8101e7d3237e23fb94f5a2e25a239035c3955269bdfd4166b0cee0a55223785f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.10
|
Security for oxigen-pipeline 1.5.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.