4
$\begingroup$

I'm new to machine learning and deep learning. I've wanted to solve time series problem, which has data every single second. Plus, I've been doing research on word2vector and time series data lately. And one day, I've come up with an idea transforming sequence data like date time into one-hot-encoding?

    time
2017-11-01 00:00:01
2017-11-01 00:00:02
2017-11-01 00:00:03
2017-11-01 00:00:04
.
.
.

My idea has some limitations like below,

  • too high dimensions for learning (1day = 60* 60 * 24 = 86400(s))
  • unlimited time - time will be generated every moment even right now as well
  • difference between seconds is too small to learn

I want you to determine what I'm saying above about limitations. Plus, I'd like you to give me some idea to develop time series data into one-hot-vector for machine learning and deep learning? + what do you think about this idea?

$\endgroup$

1 Answer 1

6
$\begingroup$

If you are trying to predict future values then it doesn't make sense to treat them as categorical features. There is nothing you will learn that can predict future data, since you won't see those times again.

The same holds even if you are trying to predict unseen past data but each time appears only once or a small number of times.

Instead the time values should determine the order of your training data. This way you can avoid leaking future data, and models with state can learn features from the sequential nature of the data.

However, in some cases you may want to extract additional features from the time values. Here are some examples:

  1. Time since last interesting event
  2. Number of interesting events in last time window of size n
  3. Time of day (morning / afternoon / etc)
  4. Day of week
  5. Holiday
  6. Season

Let's make up an example. Here is a dataset of times that users visited a website:

time               user
2017-11-01 00:00   Alice
2017-11-01 00:00   Bob
2017-11-02 00:00   Chris
2017-11-03 00:00   Alice
2017-11-04 00:00   Alice
2017-11-04 00:00   Bob
2017-11-07 00:00   Chris
2017-11-10 00:00   Alice

And here is the same dataset with additional features we have added:

time               user    last_visit   weekend?   time_of_day
2017-11-01 16:22   Alice   N/A          No         afternoon
2017-11-01 11:13   Bob     N/A          No         morning
2017-11-02 20:35   Chris   N/A          No         evening
2017-11-03 16:07   Alice   2 days       No         afternoon
2017-11-04 17:20   Alice   1 day        Yes        afternoon
2017-11-04 10:44   Bob     3 days       Yes        morning
2017-11-07 08:06   Chris   5 days       No         morning
2017-11-10 17:11   Alice   6 days       No         afternoon

If we are trying to predict when a certain user might visit next, then these features might help us a lot. For example we might decide that Alice is more likely to visit in the afternoon, or Bob is unlikely to visit two days in a row.

$\endgroup$
2
  • $\begingroup$ I'm not sure I fully understand what you're saying. I agree with things in the first and second paragraphs. but still confused with the last paragraph which is my goal of why I'm trying to put time data as input to find that features on your list. So, how can I handle time data and find that patterns on the above list? $\endgroup$
    – sunsets
    Jan 31, 2018 at 5:52
  • $\begingroup$ OK, updated with an example. $\endgroup$
    – Imran
    Jan 31, 2018 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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