Closed ericgermaining closed 5 years ago
Thanks @ericgermaining for taking a look at this. time_bins
are the most complicated part of the software I think. And again I did it this way for speed.
can be done, where if some one comes with their data that is already time binned, we only need to understand the boundary of the binning. I have to think about how to do that efficiently. Though I think for the time being we can let this wait, since I am not sure you have time for it, though the suggestion is great.
I thought the best way to include time_bins
as a functional is to pass them to traveltimeHMM
. Consider the following scenarios:
time_bins
object is already loaded and can be integrated in traveltimeHMM
by default. rules = list(
list(start='6:30', end= '9:00', days = 1:5, tag='MR'),
list(start='15:00', end= '18:00', days = 1:5, tag='ER')
)
time_bins <- rules2timebins(rules)
## here time_bins is a function, where you can bin the data with as
trips$timeBins = time_bins(trips$time)
In this case the traveltimeHMM
would return this functional object as part of its return list, which can be used in predict
. Or simply demand from the user to input time_bins
to the predict function. This method is easier to implement then 2.. What do you think?
@melmasri I like the functional approach, and I see that there already is a rules2timebins function in time_bins.R . However it doesn't seem to work with this example.
time_bins.R
hard-codes the conversion algorithm from time stamps to time bins, but does so in a way that allows for custom function objects incorporating other such algorithms. I see two improvement opportunities that would allow better user customization of time bins:predict.traveltime
's interface (inpredict.R
) a function object that could be passed all the way down totime_bins.R
. This would be rather easy to do considering the current architecture oftime_bins.R
.