1
$\begingroup$

Assume I want to predict if I'm fit in the morning. One feature is the last time I was online. Now this feature is tricky: If I take the hour, then a classifier might have a difficult time with it because 23 is numerically closer to 20 than to 0, but actually the time 23 o'clock is closer to 0 o'clock.

Is there a transformation to make this more linear? Probably into multiple features? (Well, hopefully not 60 features if I do the same for minutes)

$\endgroup$
  • 2
    $\begingroup$ If you are using the last time you were online, perhaps you should calculate a difference (time between "morning," whatever time you assign to that, and last time online). The difference will avoid any of the circular issues you mention. $\endgroup$ – Paul Oct 20 '17 at 13:52
  • $\begingroup$ Hm. I actually have another use case, but I wanted to keep it simple. But absolute differences to a fixed time might be a good option :-) $\endgroup$ – Martin Thoma Oct 20 '17 at 13:54
  • $\begingroup$ I've just noticed: If I take 0 o'cock as my fixed time and the absolute value, then there will be no difference between 4 o'clock and 20 o'clock... which is bad. $\endgroup$ – Martin Thoma Oct 20 '17 at 14:09
  • 1
    $\begingroup$ Why an absolute difference? Keep the negative if it appears, although if you use the reference time as the point you are making a prediction, you never should have a negative difference, Since the negative difference would imply using future information to make a past prediction. $\endgroup$ – Paul Oct 20 '17 at 14:16
  • $\begingroup$ I have a better example: suppose I have a shop for some leisure time activity. I record their time of visit and some other characteristics. Now I want to predict if they are unemployed. I don't have a reference point in that case. $\endgroup$ – Martin Thoma Oct 20 '17 at 14:36
2
$\begingroup$

The question was already posted, you can find the answer there :

What is a good way to transform Cyclic Ordinal attributes?

The idea is to transform your time feature into two feature : it's like if you represent the hour as the angle of the hand on the clock, and use the sin/cos of the angle as your features

| improve this answer | |
$\endgroup$

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