{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/prophet/issues/351","repository_url":"https://api.github.com/repos/facebook/prophet","labels_url":"https://api.github.com/repos/facebook/prophet/issues/351/labels{/name}","comments_url":"https://api.github.com/repos/facebook/prophet/issues/351/comments","events_url":"https://api.github.com/repos/facebook/prophet/issues/351/events","html_url":"https://github.com/facebook/prophet/issues/351","id":272536138,"node_id":"MDU6SXNzdWUyNzI1MzYxMzg=","number":351,"title":"simulated_historical_forecasts function in R doesn't take add_regressors into account","user":{"login":"roumail","id":32498483,"node_id":"MDQ6VXNlcjMyNDk4NDgz","avatar_url":"https://avatars3.githubusercontent.com/u/32498483?v=4","gravatar_id":"","url":"https://api.github.com/users/roumail","html_url":"https://github.com/roumail","followers_url":"https://api.github.com/users/roumail/followers","following_url":"https://api.github.com/users/roumail/following{/other_user}","gists_url":"https://api.github.com/users/roumail/gists{/gist_id}","starred_url":"https://api.github.com/users/roumail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roumail/subscriptions","organizations_url":"https://api.github.com/users/roumail/orgs","repos_url":"https://api.github.com/users/roumail/repos","events_url":"https://api.github.com/users/roumail/events{/privacy}","received_events_url":"https://api.github.com/users/roumail/received_events","type":"User","site_admin":false},"labels":[{"id":482448476,"node_id":"MDU6TGFiZWw0ODI0NDg0NzY=","url":"https://api.github.com/repos/facebook/prophet/labels/bug","name":"bug","color":"ee0701","default":true},{"id":657441141,"node_id":"MDU6TGFiZWw2NTc0NDExNDE=","url":"https://api.github.com/repos/facebook/prophet/labels/ready","name":"ready","color":"0052cc","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/facebook/prophet/milestones/3","html_url":"https://github.com/facebook/prophet/milestone/3","labels_url":"https://api.github.com/repos/facebook/prophet/milestones/3/labels","id":2399276,"node_id":"MDk6TWlsZXN0b25lMjM5OTI3Ng==","number":3,"title":"v0.3-release","description":"","creator":{"login":"seanjtaylor","id":7317,"node_id":"MDQ6VXNlcjczMTc=","avatar_url":"https://avatars0.githubusercontent.com/u/7317?v=4","gravatar_id":"","url":"https://api.github.com/users/seanjtaylor","html_url":"https://github.com/seanjtaylor","followers_url":"https://api.github.com/users/seanjtaylor/followers","following_url":"https://api.github.com/users/seanjtaylor/following{/other_user}","gists_url":"https://api.github.com/users/seanjtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/seanjtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanjtaylor/subscriptions","organizations_url":"https://api.github.com/users/seanjtaylor/orgs","repos_url":"https://api.github.com/users/seanjtaylor/repos","events_url":"https://api.github.com/users/seanjtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/seanjtaylor/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":29,"state":"open","created_at":"2017-03-20T22:18:34Z","updated_at":"2018-08-01T19:10:48Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2017-11-09T11:48:33Z","updated_at":"2018-08-23T23:32:20Z","closed_at":"2018-06-07T18:20:17Z","author_association":"NONE","body":"Hi,\r\n\r\nI am using prophet in R.\r\n\r\nWhen performing cross validation, we have the following block of code from simulated_historical_forecasts, internally called by cross_validation:\r\n\r\n```\r\n  for (i in 1:length(cutoffs)) {\r\n    cutoff <- cutoffs[i]\r\n    m <- prophet_copy(model, cutoff)\r\n    history.c <- dplyr::filter(df, ds <= cutoff)\r\n    m <- fit.prophet(m, history.c)\r\n    df.predict <- dplyr::filter(df, ds > cutoff, ds <= cutoff + \r\n                                  horizon)\r\n    columns <- c(\"ds\")\r\n    if (m$growth == \"logistic\") {\r\n      columns <- c(columns, \"cap\")\r\n      if (m$logistic.floor) {\r\n        columns <- c(columns, \"floor\")\r\n      }\r\n    }\r\n    future <- df[columns]\r\n    ### Missing the addition of add_regressors/add_holidays###\r\n    yhat <- stats::predict(m, future)\r\n    df.c <- dplyr::inner_join(df.predict, yhat, by = \"ds\")\r\n    df.c <- dplyr::select(df.c, ds, y, yhat, yhat_lower, \r\n                          yhat_upper)\r\n    df.c$cutoff <- cutoff\r\n    predicts <- rbind(predicts, df.c)\r\n  }\r\n```\r\n\r\nAs seen here, we need to have the regression column in the future df when we call `predict`\r\nhttps://facebook.github.io/prophet/docs/seasonality_and_holiday_effects.html\r\n\r\nThe future dataframe incorporates growth (via the m$growth check) but not additional regressors. There should be an additional conditional checking if extra_regressors are present and include them in the future df. Currently I get the error: setup_dataframe, column not found.\r\n\r\nSuggested addition:\r\n```\r\nif (length(m$extra_regressors) > 0) {\r\n      regressor_names <- names(m$extra_regressors)\r\n      columns <- c(columns, regressor_names)\r\n    }\r\n```\r\nPlease let me know if you need any more details on my side. Thank you for the great work on the package. It is superb!\r\n\r\nRohail\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/prophet/issues/comments/415605336","html_url":"https://github.com/facebook/prophet/issues/351#issuecomment-415605336","issue_url":"https://api.github.com/repos/facebook/prophet/issues/351","id":415605336,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTYwNTMzNg==","user":{"login":"BisselChutzpah","id":37591245,"node_id":"MDQ6VXNlcjM3NTkxMjQ1","avatar_url":"https://avatars1.githubusercontent.com/u/37591245?v=4","gravatar_id":"","url":"https://api.github.com/users/BisselChutzpah","html_url":"https://github.com/BisselChutzpah","followers_url":"https://api.github.com/users/BisselChutzpah/followers","following_url":"https://api.github.com/users/BisselChutzpah/following{/other_user}","gists_url":"https://api.github.com/users/BisselChutzpah/gists{/gist_id}","starred_url":"https://api.github.com/users/BisselChutzpah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BisselChutzpah/subscriptions","organizations_url":"https://api.github.com/users/BisselChutzpah/orgs","repos_url":"https://api.github.com/users/BisselChutzpah/repos","events_url":"https://api.github.com/users/BisselChutzpah/events{/privacy}","received_events_url":"https://api.github.com/users/BisselChutzpah/received_events","type":"User","site_admin":false},"created_at":"2018-08-23T23:32:20Z","updated_at":"2018-08-23T23:32:20Z","author_association":"NONE","body":"Hi,\r\n\r\nIs the bug really fixed in Python as well?\r\n\r\nStill receiving a ValueError:\r\n\r\n#Random Dataset Preparation\r\nimport random\r\nrandom.seed(a=1)\r\ndf = pandas.DataFrame(data = None, columns = ['ds', 'y', 'ex'], index = range(50))\r\ndatelist = pandas.date_range(pandas.datetime.today(), periods = 50).tolist()\r\ny = numpy.random.normal(0, 1, 50)\r\nex = numpy.random.normal(0, 2, 50)\r\ndf['ds'] = datelist\r\ndf['y'] = y\r\ndf['ex'] = ex\r\n\r\n#Model\r\nprophet_model = Prophet(seasonality_prior_scale = 0.1)\r\nProphet.add_regressor(prophet_model, 'ex')\r\nprophet_model.fit(df)\r\nprophet_forecast_step = prophet_model.make_future_dataframe(periods=1)\r\n\r\n#Result-df\r\nprophet_x_df = pandas.DataFrame(data=None, columns=['Date_x', 'Res'], index = range(int(length_test_data)))\r\n\r\n#Error\r\nprophet_x_df.iloc[0,1] = prophet_model.predict(prophet_forecast_step).iloc[0,0]\r\n\r\n\r\nValueError: Regressor \"ex\" missing from dataframe"}}
{"actor":{"display_login":"BisselChutzpah"}}