Skip to content
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

Cross Validation with regressors #380

Closed
ghost opened this issue Dec 14, 2017 · 13 comments
Closed

Cross Validation with regressors #380

ghost opened this issue Dec 14, 2017 · 13 comments

Comments

@ghost
Copy link

ghost commented Dec 14, 2017

I am having issues using the cross_validation function when I add regressors to my prophet function. I have not been able to find any documentation within prophet nor have I seen any examples of people using cross_validation() after adding regressors to their model. The error I receive is always

"Error in setup_dataframe(object, df) :
Regressor "bookings" missing from dataframe"

@roumail
Copy link

roumail commented Dec 15, 2017

Hey,

Just a quick check: When you add regressors, you need to add them to the training data and then specify them using add_regressors. The latter function seems to fail because the regressor bookings isn't found in the training data you pass to cross_validation.

Are you specifying the same name?

@ghost
Copy link
Author

ghost commented Dec 18, 2017 via email

@roumail
Copy link

roumail commented Dec 18, 2017

Does prophet_df contain a column by the name bookings?

@ghost
Copy link
Author

ghost commented Dec 18, 2017 via email

@bletham
Copy link
Contributor

bletham commented Dec 22, 2017

This is a bug, sorry about that. See also #351.

It has been fixed in the current github version, which you can install with

devtools::install_github('facebook/prophet', subdir='R', ref='master')

We'll be pushing the fix to CRAN soon.

@rpanai
Copy link

rpanai commented Jan 10, 2018

@bletham is there a similar bug on the python version too?

@bletham
Copy link
Contributor

bletham commented Jan 22, 2018

@rpanai yes this bug exists in the python version also. It is fixed fixed in the current master branch here on github, so if you download and install that it will work correctly.

@nielsenmarkus11
Copy link

@bletham, I have a quick clarification question. When prophet cross_validates in the rolling window with regressors that are also time series (eg. using temperature to predict pollution), does it actually predict the regressors for the horizon as well as the response variable? Or does it use the actual data from the regressors? Thanks,

@bletham
Copy link
Contributor

bletham commented Feb 13, 2018

It does not predict the regressors. They are taken as "known" and so the true values are used for them. If the future values of the regressors are in reality coming from another Prophet forecast then it would be correct (and probably important) to also forecast the regressors like you described.

Currently we don't know where future values for regressors are coming from (deterministic? prophet? some other forecasting method?) and so there wouldn't be a way to do this. But making an interface to cross_validate that makes this possible would be good, I made an issue for this in #442.

By the way, if you have a successful example of using other prophet forecasts as extra regressors, I'd love to see it.

@nielsenmarkus11
Copy link

Thanks @bletham . I currently just have my code in a simple for loop running prophet() for each of the regressors then I do the same for the response variable using the yhat values from each of the forecasted regressors. I'll take a look at the issue you provided above and see if I can send a simple example to you. I'm assuming you'd prefer it all to be automated within the cross_validate function?

@bletham
Copy link
Contributor

bletham commented Feb 19, 2018

That seems reasonable.

Maybe for starters we'd keep it as a separate function, for cross validation with Prophet extra regressors. I think we'd need to pass in the prophet models for each of the regressors to have correct parameter settings for them in the CV.

@nielsenmarkus11
Copy link

You can find my loop here in one of my repositories. I'm using temperature, wind, and precipitation to predict PM2.5. Let me know how else I can help.

@bletham
Copy link
Contributor

bletham commented May 25, 2018

I'm going to close this to merge it with #351, which is tracking the root issue.

@bletham bletham closed this as completed May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants