Project completed in week 3 (12.10.-16.10.20) of the Data Science Bootcamp at Spiced Academy in Berlin.

I really enjoyed this week’s project for two main reasons: it involved time series analysis and it solved a real-world practical business problem.

### Exploratory analysis

The dataset includes 12 variables, of which 3 are dependent, and 1 is actually the one I had to predict: bike count. I started by extracting the month, day, weekday, and hour from the datetime feature, so I ended up with 15 variables to help me predict the bike count.

It’s a common assumption that the more variables you have in a dataset and include in a model, the better the predictions. But usually (as in this case) it’s exactly the contrary. The more variables you have, the higher the chance that some of them will be correlated with each other (multicollinearity) or just be irrelevant. Also, some variables that seem useless independently might be useful combined. Selecting what features to include in the model can be quite tricky, but a look at the correlation matrix or the sklearn.feature_selection module can help!

In the bike dataset, I noticed a high correlation between temperature, season, windspeed, season, and month, which was not surprising. I used this information, as well as the Recursive Feature Elimination (RFE), to select the most relevant variables for the bike count prediction. In the end, I included only five features: temperature, hour, weather, weekday, and holiday.

### Feature engineering

After selecting the features, I had to do a bit of feature engineering to prepare them for Linear Regression. I tried both with scaling and polynomial expansion. For the Random Forest models, this was not necessary, since the models do feature engineering themselves. The feature engineering part was very important also for fitting the evaluation score used in the Kaggle competition, which in this case was Root Mean Squared Log Error (RMSLE). In order to optimize my models against the RMSLE, I took the logarithm of the target variable(bike count).

### Regression models

Once the dirty work was done, I trained and tested four different regression models:

• RFR1: Random Forest Regressor with default hyperparameters
• RFR2: Random Forest Regressor with the best hyperparameters found with GridSearchCV
• RFR3: Random Forest Regressor with hyperparamenters recommended by TPOT