Project · 2025
← All workBike Sharing Demand Prediction
Regression models to predict hourly London bike sharing demand from weather, time and calendar features. Compared linear regression, ElasticNet, Random Forest and XGBoost with nested cross-validation; a tuned Random Forest reached RMSLE 0.30 on the test set (a log-scale error; lower is better).
Overview
Predicts bike sharing demand from weather, time and calendar features. Most of the work went into preprocessing and a fair comparison of linear and tree-based regression models.
The problem
- Handling multiple feature types (categorical, numerical, temporal)
- Dealing with seasonality and time-based patterns
- Selecting the best model from various regression approaches
What we built
- Implemented preprocessing: scaling, one-hot encoding, PCA/LDA
- Trained and compared linear regression, ElasticNet, Random Forest and XGBoost
- Selected the model with nested cross-validation scored on RMSLE, then tuned it with a randomized search
Results
- Random Forest won the model search; after tuning it scored RMSLE 0.226 on train and 0.298 on test
- A custom transformer regroups weather codes into fewer classes before encoding
- PCA, LDA and feature selection were tested; the best model used none of them
How it works
The data is the London bike sharing set: hourly rentals with weather, temperature, humidity, wind and calendar flags. Two percent of values were removed at random on purpose, so the pipeline has to impute gaps the way it would with a real feed.
A single scikit-learn pipeline handles imputation, scaling, one-hot encoding and optional dimension reduction (PCA, LDA or sequential feature selection), so every model is compared on exactly the same preprocessing.
Model choice uses nested cross-validation (5 outer folds) on RMSLE, which penalizes relative error and suits counts that range from a handful to thousands. Random Forest won, a randomized search tuned it, and learning and validation curves show how it behaves as data and depth grow.