# How can I deal with circular features like hours? [duplicate]

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)

• 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.
– Paul
Oct 20 '17 at 13:52
• 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 :-) Oct 20 '17 at 13:54
• 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. Oct 20 '17 at 14:09
• 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.
– Paul
Oct 20 '17 at 14:16
• 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. Oct 20 '17 at 14:36