We have transformed the raw time data into a categorical feature that represents the hour of the day in which the rating was given.
Now, say that we decide this is too coarse a representation. Perhaps we want to further refine the transformation. We can assign each hour-of-the-day value into a defined bucket that represents a time of day.
For example, we can say that morning is from 7 a.m. to 11 a.m., while lunch is from 11 a.m. to 1 a.m., and so on. Using these buckets, we can create a function to assign a time of day, given the hour of the day as input.
In Scala, we define a function which takes inputer as absolute HR in 24 HR format and returns time of day: morning, lunch, afternoon, evening, or night:
def assignTod(hr ...