Encoding Time Values

0

I am using Python/Scikit to do data encoding before I go ahead and train my Neural Network. I have a few columns that look like this

07:05:00
08:41:00
17:25:00
12:58:00
08:56:00
11:59:00
17:25:00
15:24:00

Any suggestions on how to encode this? Or is leaving it like this fine?

Patrick Zawadzki

Posted 2017-06-29T16:26:25.203

Reputation: 101

1https://datascience.stackexchange.com/a/2370/23305 – oW_ – 2017-06-29T17:36:23.187

i recommend using datetime in python to extract features from the timestamp: https://docs.python.org/2/library/datetime.html

– Vadim Smolyakov – 2017-08-16T19:30:56.843

Answers

0

I have decided to convert the strings into seconds. Since these are all Time of Day values, I will convert them to contiguous seconds.

https://stackoverflow.com/questions/10663720/converting-a-time-string-to-seconds-in-python

Patrick Zawadzki

Posted 2017-06-29T16:26:25.203

Reputation: 101

in your training (and test) data did you then replaced the Date_time column with a 'contiguous_secs' (int) column? – sAguinaga – 2019-12-09T17:20:35.287

1

A common step in "feature engineering" is parsing these out into multiple values that might give you additional information during ML. For example:

  • Hour of the day
  • Minute of the hour
  • Hours after sunrise
  • Hours before sunset

If you also had day, that would open a lot more to detect seasonality like:

  • Month of the year
  • Month of the quarter
  • Day of the week
  • Holiday Y/N

CalZ

Posted 2017-06-29T16:26:25.203

Reputation: 1 548