An end-to-end MLOps pipeline for predicting hotel reservation cancellations. This project leverages LightGBM for classification, Optuna for hyperparameter optimization, and MLflow for experiment tracking and model management.
The goal of this project is to predict the booking_status (Canceled vs. Not Canceled) of hotel reservations. This enables:
- Revenue Management: Better forecasting of cancellations.
- Targeted Marketing: Identifying customers likely to cancel and offering incentives.
- Operational Efficiency: Optimizing room allocation.
- Language: Python 3.12+
- Dependency Management: uv
- Model: LightGBM
- Hyperparameter Tuning: Optuna
- Experiment Tracking: MLflow
- Data Storage: Google Cloud Storage (GCP)
- Data Format: Parquet (for intermediate storage)
- Preprocessing: Scikit-learn, Imbalanced-learn (SMOTE)
├── artifacts/ # Data and model artifacts
├── config/ # Configuration files (YAML and Python)
├── logs/ # Application logs
├── mlruns/ # MLflow tracking data
├── pipeline/ # Pipeline script
└── pipeline.py
├── src/ # Source code for the pipeline
│ ├── data_ingestion.py # GCP download and data splitting
│ ├── data_preprocessing.py # Feature engineering and balancing
│ ├── model_training.py # Training with Optuna and MLflow
│ ├── logger.py # Logging configuration
│ └── custom_exceptions.py # Custom error handling
├── utils/ # Shared utility functions
├── pyproject.toml # Project dependencies and metadata
└── README.md # Project documentation
- uv installed.
- GCP Service Account Key (JSON) with access to the configured bucket.
Create a .env file in the root directory:
GOOGLE_APPLICATION_CREDENTIALS="path/to/your/service-account-key.json"uv syncThe pipeline is split into three main stages. You can run them sequentially or with the pipeline script:
Downloads the raw dataset from GCP and performs an initial train-test split.
uv run python -m src.data_ingestionHandles categorical encoding, log transformation for skewed features, data balancing using SMOTE, and feature selection using a Random Forest importance ranking.
uv run python -m src.data_preprocessingTrains a LightGBM model with:
- Hyperparameter Tuning: 100 trials using Optuna.
- MLflow Tracking: Automatically logs parameters, metrics (Accuracy, Precision, Recall, F1), and artifacts (datasets and the final model).
uv run python -m src.model_traininguv run pipeline.pipelineTo visualize the training results, metrics, and compare different runs:
- Start the MLflow UI:
mlflow ui
- Open
http://localhost:5000in your browser.
The project uses the Hotel Reservations Classification Dataset from Kaggle.
- Target:
booking_status - Features: Includes lead time, average price per room, special requests, and more.