Search code examples
pythonmachine-learningscikit-learn

Train machine learning model with scikit learn for time-series prediction


I need to train a model with scikit-learn to predict possible time for less people in a room.

Here is how my dataset looks like:

Time                          PeopleCount
---------------------------------------------
2019-12-29 12:40:10               50
2019-12-29 12:42:10               30
2019-12-29 12:44:10               10
2019-12-29 12:46:10               10
2019-12-29 12:48:10               80
and so on...

This data will be available for 30 days.

Once the model is trained, I will query the model to get the possible time when there will be fewer people in the room between 10.AM and 8.PM. I expect the machine learning model to respond back with the 30-minute accuracy, ie. "3.00 PM to 3.30PM"

What algorithm can I use for this problem and how can I achieve the goal? Or are there any other Python libraries than SciKit-Learn which can be used for this purpose?


Solution

  • First of all, time-series prediction is on the base of theory that current value more or less depend on the past ones. For instance, 80 of people count as of 2019-12-29 12:48:10 has to be strongly influenced on the people count at the time of 12:46:10, 12:44:20 or previous ones, correlating with past values. If not, you would be better off using the other algorithm for prediction.

    While the scikit package contains a various modules as the machine learning algorithm, most of them specialize in the classification algorithm. I think the classification algorithm certainly satisfy your demand if your date is not identified as the type of time series. Actually, scikit also has some regression module, even though I think that seem not to be well suitable for prediction of time series data.

    In the case of prediction of time series data, RNN or LSTM algorithm (Deep Learning) has been widely utilized, but scikit does not provide the build-in algorithm of it. So, you might be better off studying Tensorflow or Pytorch framework which are common tools to be enable you to build the RNN or LSTM model.