1
$\begingroup$

This is my first time posting here. I'm usually on SO. So I'm not sure if these kind of questions fit into DS stackexchange. I genuinely need opinions on this.

What data do I have -

+-----------+------------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+------+-------+------+-------+------+----------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+----------+----------+----------+----------+
|    Day    |    Date    | 0:0 | 0:30 | 1:0 | 1:30 | 2:0 | 2:30 | 3:0 | 3:30 | 4:0 | 4:30 | 5:0 | 5:30 | 6:0 | 6:30 | 7:0 | 7:30 | 8:0 | 8:30 | 9:0 | 9:30 | 10:0 | 10:30 | 11:0 | 11:30 | 12:0 | 12:30 pm | 1:00 pm | 1:30 pm | 2:00 pm | 2:30 pm | 3:00 pm | 3:30 pm | 4:00 pm | 4:30 pm | 5:00 pm | 5:30 pm | 6:00 pm | 6:30 pm | 7:00 pm | 7:30 pm | 8:00 pm | 8:30 pm | 9:00 pm | 9:30 pm | 10:00 pm | 10:30 pm | 11:00 pm | 11:30 pm |
+-----------+------------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+------+-------+------+-------+------+----------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+----------+----------+----------+----------+
| Tuesday   | 01/01/2019 |   2 |    2 |   2 |    2 |   2 |    2 |   2 |    2 |   2 |    1 |   1 |    1 |   1 |    1 |   1 |    1 |   1 |    1 |   1 |    1 |    1 |     1 |    1 |     1 |    9 |        9 |       8 |       8 |       8 |       8 |       1 |       1 |       9 |       4 |      10 |      10 |       8 |       8 |       8 |       4 |       4 |       8 |       8 |       8 |        4 |        8 |        5 |        5 |
| Wednesday | 02/01/2019 |   8 |    9 |   1 |    1 |   1 |    1 |   1 |    1 |   1 |    1 |   1 |    1 |   1 |    1 |   1 |    1 |   1 |    1 |   9 |    9 |    5 |     9 |    3 |     3 |    3 |        3 |       3 |       3 |       3 |       3 |       3 |       3 |       3 |       3 |       3 |       9 |       1 |       1 |       1 |       9 |      12 |      12 |       3 |       3 |       10 |       10 |        4 |        4 |
+-----------+------------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+-----+------+------+-------+------+-------+------+----------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+----------+----------+----------+----------+

Each row is a day with 48 columns. Each column is half an hour of clock, starting from midnight to 11:30pm. Each number in the column represents a particular category.

For instance, if we see the first row of Tuesday at column 0:0, the value is 2. Here 2 represents category - Social Time. Similarly, 1 represents category - sleep and all numbers state what I was doing at that particular hour of day.

I have this data for about last 2 years so around 700 x 48 data points.


What am I aiming for -

Based on this data, I want to predict my next/future day or hour

Where am I stuck -

My predictor variable is the entire row (the day) or a single column (30 mins). My first thought was to pivot the whole data, do one-hot encoding for each response variable and then think on which classification model to apply. But then each day is also related to the day before it. So it's merely not a classification problem. There's some regression to it as well.

I'm having hard time in which way should I prepare the data and proceed.


What am I asking for -

An approach to handle this kind of dataset.

I'm not necessarily looking for which model to apply. My primary concern is to understand in which way to prepare my data such that it is ready for consumption in a model.

Any help, guidance, similar Q&A or related article will be helpful.

$\endgroup$
1
$\begingroup$

I can think of two ways for doing this.

One would be to have the same data structure as you currently have. Then you can train any regression model with all of your columns as features. You can use LinearRegressor or RandomForestRegressor , etc. Then to predict multiple values as in multiple columns you need to use something like "multioutputregressor". This way you are feeding the model data of one day and model predicts the next day for you. So you can get multiple predictions (output) out of the model.

The other way that you can do this is to convert your columns into multiple rows. For example you can have something like this:

+-----------+-----------------+-------+
|    Day    |    Date         | value |
+-----------+-----------------+-------+ 
| Tuesday   | 01/01/2019 0:0  |   2   |
| Tuesday   | 02/01/2019 0:30 |   2   |
| Tuesday   | 02/01/2019 1:0  |   2   |
| Tuesday   | 02/01/2019 1:30 |   2   |
| Tuesday   | 02/01/2019 2:0  |   2   |
| Tuesday   | 02/01/2019 2:30 |   2   |
+-----------+-----------------+-------+

Then you can use one of the Regressor models as mentioned above, to predict one row, that is one half an hour. Then you can put this prediction back into the data, train the model again and predict for the next half an hour. You can continue to do this until you have a complete day of predictions.

Hope this helps,

$\endgroup$

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.