Skip to main content
Data Science
What this does: Finds the best model settings automatically using Bayesian optimization, improving prediction accuracy without manual trial-and-error — saving days of data science effort per training cycle.
The system uses a production-grade CatBoost pipeline with persistent Bayesian optimization, designed for high-throughput scaling and reproducible experiments.

Training Pipeline

1

Data Preparation

Features are engineered with time-based lags and rolling windows. Data is split using a chronological 80/20 split (preserving temporal order) to prevent look-ahead bias, ensuring the model is always evaluated on future data relative to the training set.
2

Hyperparameter Optimization

Optuna explores the search space using a . Unpromising trials are pruned early using a MedianPruner.
3

Production Model Selection

The trial with the lowest RMSE is selected as the winner. The final model is retrained on the full dataset using the best hyperparameters found.

Persistent Optimization

Unlike standard in-memory optimization, our system persists the entire state of the hyperparameter search to a PostgreSQL database.

Key Benefits

  1. Resume Capability: If the pipeline crashes, it resumes from where it left off.
  2. Parallel Execution: Multiple Airflow workers can run trials concurrently.
  3. Historical Analysis: Query the database later to analyze hyperparameter trends.

Implementation

Configuration

Persistence: Optuna studies are saved to postgresql://airflow:airflow@postgres:5432/optuna.

Advanced Training Modes

The DAG supports two additional training strategies, enabled via parameters.yml:
Finds Pareto-optimal solutions balancing multiple metrics (RMSE and MAE).
  • Trials: 50 (configurable via multi_objective_trials)
  • Weights: RMSE 60%, MAE 40%
  • Enable: advanced_features.enable_multi_objective: true

Model Comparison

The pipeline also trains a Random Forest baseline via the demand_modeling Kedro pipeline and compares it head-to-head against CatBoost using RMSE, MAE, and MAPE. The winning model is selected automatically.

Evaluation Metrics

We prioritize RMSE for optimization, but monitor multiple metrics for business context.
Root Mean Squared Error: The primary objective function.RMSE=1n∑t=1n(yt−y^t)2RMSE = \sqrt{\frac{1}{n} \sum_{t=1}^{n} (y_t - \hat{y}_t)^2} It penalizes larger errors more heavily.

Optuna Visualization

MLflow Integration

All training runs are automatically logged to the MLflow Tracking Server.
  • Model Registry: Models are registered under demand_forecasting_catboost.
  • Metrics: cv_rmse_mean, final_rmse, final_mae, final_mape.
  • Artifacts: Code snapshots, regressor.pickle.

Parameters

Full search space configuration and feature engineering settings.

Experiment Tracking

MLflow integration for logging metrics, artifacts, and model registry.