Skip to main content

Data pipeline: extract → classify → clean → split -> Model

Project description

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:

    • StandardScaler para 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: premodel.

  • Tuning con RandomizedSearchCV y selección por R² de validación.

  • Evalúa en test y arma model_report.html con:

    • 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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oxigen_pipeline-1.5.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oxigen_pipeline-1.5.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file oxigen_pipeline-1.5.0.tar.gz.

File metadata

  • Download URL: oxigen_pipeline-1.5.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for oxigen_pipeline-1.5.0.tar.gz
Algorithm Hash digest
SHA256 bd101833fe5636defd63d59cf557ccbb914bce19856dfe5223703bf782ce5a20
MD5 f0c255bb68855991d20f4e686cb75f20
BLAKE2b-256 273b734021b030f34e7d8266d353ec3e10b7fb4825adea5b9b7c98c61b87374d

See more details on using hashes here.

File details

Details for the file oxigen_pipeline-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for oxigen_pipeline-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46355479052906ce41823a33ee7b9b927d8bff53c85f665cdd4082c57102bc74
MD5 de2c6848d0f090a5bdfeacea58653e4c
BLAKE2b-256 8101e7d3237e23fb94f5a2e25a239035c3955269bdfd4166b0cee0a55223785f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page