0
$\begingroup$

I am trying to use xgboost for performing some regression and the features I have are rather simple and limited. I have the time stamp associated with some measurements. The measurements are customer counts and the dependent variable is predicting the average customer wait time. There is dependence on time of the day and weekends as well. For example, I notice that wait times are longer in thee afternoon than in the morning and evenings. There is also a dependency on weekday, holiday or weekends. So I also added a boolean variable to indicate whether the given day is a weekend or holiday or not.

The time data I have is in 10 minutes interval and is a regular python time stamp with the date, hours, minutes and second granularity. How should such time features be included with xgboost or random forests or indeed any such modelling paradigms?

$\endgroup$
1
$\begingroup$

You have already constructed features that indicate relevant events like weekday, holiday and so on, this is good. Create as many such features you can come up with.

As for the time of day, I'd try using the hour only and combination of hour+minute. Probably less important is the minute alone, unless there is something that causes spikes at the same times of every hour.

Since you use tree-based models, you don't need to normalize. Mark your time features as categorical (can you do that in xgboost? I forgot, but I think you can in lightgbm) or as boolean where applicablen. And then check feature importances, which you can with gradient boosted tree type of models.

Finally, make sure your validation splits are good, which can be a challenge whenever you have some kind of time involved. Make sure your don't leak information and that your validation set is representative.

$\endgroup$
  • $\begingroup$ Thanks for the answer. I guess hour could be an integer/discrete variable running between 0-23 or is it worth it to make time as a continuous variable for hour and minutes? Mark your time features as categorical: Do you mean the weekend/holiday like boolean variables? Could you also clarify on your last point. Make sure your don't leak information and that your validation set is representative.. I was going to use some continuous data history as training and maybe predict use an hour or so worth of future data (relative to training set) as validation set. $\endgroup$ – Luca Sep 11 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.