-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
holdout function to specify length using common language #180
Comments
I'm sorry to kind of step on the toes of #177 . I wasn't sure if I should reply to that, since they are asking for a current method and I'm talking about a new function that might wind toward that. |
I like this suggested interface, it is definitely simpler to understand. |
My fear for I'm not sure there's any reason you would use
or
I think the second is a pretty decent way to go about it, but I realize that the models that are generated in the |
In practice, if the models that are fit during the |
Not expanding the tsibble structure is something @earowang and I have discussed before for Thinking about this again now, a possible solution for the mable issue is to create a 'folded model', which contains a model for each fold in the input data to match the input tsibble's key structure. The issue remains when you use model methods that return a tsibble/fable, as the forecasts/residuals/etc are now unique for each fold. Any thoughts on this would be very useful, I don't think CV is in a great spot right now and improvements would be welcomed. |
The goal of cross-validation is to understand the pattern of residuals in serial holdouts, yes? So we don't really care about the fitted models, just the forecasts and maybe the fitted values for each model. Those are unique by the fold and by the model. A fable object that is augmented with a column denoting the fold (by last observation index, etc) would contain all of the information we need. This could also be managed with a mable-like object that holds fables for each model in corresponding columns, with rows for keys. Both would allow us to perform the tasks needed:
I feel like the extended fable is more parsimonious than the mable-of-fables concept, personally. |
For a For a
|
One slight issue, when things scale up, with storing the |
Distribution object sizes should be fixed by https://github.com/mitchelloharawild/distributional, which I am currently converting the fabletools code to use. |
You're a king, @mitchelloharawild . |
This is another spot where the iteration operator would be helpful, though it would be operating over model specifications and |
By this do you suggest an alternative to There are a couple reasons why this hasn't been done yet (but hopefully will be later)
|
To address 1., I don't think it's actually useful to hold onto the model object in CV. If the purpose of CV is to determine accuracy on successive holdouts, you can hold only the forecast distribution (or even just the mean, depending on what accuracy metrics you're asking for), eventually comparing those to the actual values. I'm definitely on board with the idea of not having the data actually replicated. In the above, the The reason I worry about letting |
I agree that the most common task for CV style folding over time is evaluating forecast accuracy, and that there should be a more efficient and simple workflow for doing this task. However I also think that more value can be extracted from the model objects, for example you could look at how the parameters vary over time to evaluate how often the model should be re-estimated.
I'm interested in your experience of nesting |
I'll run an experiment tomorrow on the nested It seems like the key to reducing the overall memory footprint of a CV process might be to determine what you are asking for in the output beforehand. It can be frustrating, since I've definitely rerun CVs multiple times because I remembered something extra I wanted out of it. Still, I think having it default to essentially giving you a One option is to have the output be a |
By default, nested As @davidtedfordholt said, it's more efficient to parallelize on the highest dimension (model or series). In the context of CV, especially with a stretching window, you very often end up with many more folds than models. Parallelizing each model is inefficient if you have long series because too much time is spent on transferring the exact same data for each model.
In the same vein, a solution could be to have separate functions or an argument to return fitted models along with the forecasts. Keeping the models can indeed be useful but they dramatically increase the memory footprint and slow down the CV as well because you need to return more data to the main thread. It would be nice if the user could choose to pay that price depending on what he intends to do. |
It would be nice to specify a holdout period without having to use
filter
. It gets tricky if different series in atsbl
have different dates for their final observation. I suggest a function that takes either a length of holdout (e.g. "14 days") or a number of observations, as well as an optionalstart_date
(or a number that represents how many observations from the end would be the first observation in the holdout, to deal with the problem of different end dates).This would be a step in the direction of cross-validation, especially if you passed the length of the holdout into the models such that
forecast
could automatically forecast for the length of the holdout. The above would work relatively simply, and a CV would, in a sense, just be mapping that over a list ofcutoff_dates
(or inverse-ordered observation numbers) with the same holdout period, leading to acv-fbl
that adds a column for the cutoff date.The cross-validation would be relatively simple as:
can generate a nested table or the like (converting cv_length and cv_horizon to numbers of observations in the frequency of the
tsbl
) with rows corresponding the the keys and thecutoff_dates
per key, generated as simply as:From there, for a given key, you are just slicing the
tsbl
off at eachcutoff_date
in the list, modeling and forecasting, then binding thefbl
results with a column for the cutoff as an additional index.The text was updated successfully, but these errors were encountered: