# Time series data combined with multiple feature. Predicting difference from the mean

I'm trying to predict the % attendance of people to gym classes that have previously been booked. It is heavily dependent on the time of day and also a load of other features (is it raining, fraction of class that booked yesterday compared to a week ago, etc.). Random forest alone performs very poorly.

Instead, I tried to predict the difference from the mean for the hour of the day using random forest. Then I just add that on to the mean to recover the desired estimate.

This again performs worse than just the mean itself.

1. Is this approach (predicting the difference from the mean) a bad idea?
I can't find people using similar methods which makes me think it isn't a good idea.

2. Is there a better algorithm suited to this task?

• You added that your MAPE is ~60% but it is hard to judge that. Have you calculated the MAPE of simply using the average attendance as a predictor to have a baseline of quality? If the MAPE of your current model is the same/worse than the baseline you might have an issue of code error / wrong model / wrong parameters, etc. If it is already better however you just need to improve further by deploying parameter optimization, feature engineering, etc. Apr 23, 2020 at 12:21

With random forest there is no need to modify your output variable (i.e difference from the mean) when performing a regression.

It may be that the features you have are not relevant, or that you don't have enough data. Also try different model parameterisations (num trees, num layers etc).

Try to do some feature engineering to create intelligent features that might help the classifier.

• You mean i should just try to predict the attendance fraction? Rather than difference from the mean for that hour? Because if i do that i get poor accuracy (MAPE=~60%) . It seems to not handle the time series aspect very well. Aug 26, 2018 at 14:32
• Please can you give a single example of the input vector, and a single example of the output you want. Aug 26, 2018 at 15:01
• Yes, sorry. Input vector would be time and date of bookable slot, whether it is raining (1 or 0), percentage of attendees that booked today, percentage of attendees that booked a week ago, percentage that booked longer than a week ago. Then the target would be the percentage of people who attended out of the spaces that were booked. Aug 26, 2018 at 15:31
• And the time and date would refer go up in hour slots. E.g 26/08/2018 1pm next slot would be 26/08/2018 2pm. Ive split this into hour of day and day of week Aug 26, 2018 at 15:46
• Ok, are you including the date in the input, or only the day of week and hour? Aug 26, 2018 at 18:28

I think you have too few features. Try to do some feature engineering.

Time series have a wealth of information, but it needs to be extracted somehow. Have you looked at things like stationarity/seasonality (for days, weeks months)? These can help you find more relevant features.

First, use the very data as features. Have a variable with the number of the day, the number of the week, the number of the month. Also try to have some general.

You already have "lag" features (values from previous days), but you can also try something like a moving window or expanding window augmented with statistics like maximum or mean or std attendance value for the time the window encompases.

I know that I just stated some terms but you will find implementations with some googling. Having more features is the first step, then you can perform some sort of feature selection to keep only the best of them.