Skip to content

Commit

Permalink
Merge pull request #19 from petersen-f/fix_prediction
Browse files Browse the repository at this point in the history
Fixes future prediction and other bugs
  • Loading branch information
vandenman authored Dec 12, 2023
2 parents 5f855d1 + 9b239b1 commit 7d84440
Show file tree
Hide file tree
Showing 4 changed files with 438 additions and 298 deletions.
11 changes: 4 additions & 7 deletions R/modelFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


colnames(trainData)[colnames(trainData)=="time"] <- "ds"
m <- prophet::prophet(...,weekly.seasonality = F,changepoint.range = 0.9)
m <- prophet::prophet(...)
if(formula != as.formula("y ~ time")){
for(reg in labels(terms(formula))[-1])
m <- prophet::add_regressor(m,reg)
Expand All @@ -60,12 +60,9 @@

.prophetPredictHelper <- function(fit,testData, horizon,recursive = F,...){

if(is.null(testData))
future <- prophet::make_future_dataframe(fit, periods = horizon,freq = 33,include_history = F)
else if(!is.null(testData)){
future <- data.frame(ds = testData$time)
future[,names(fit$extra_regressors)] <- testData[,names(fit$extra_regressors)]
}

future <- data.frame(ds = testData$time)
future[,names(fit$extra_regressors)] <- testData[,names(fit$extra_regressors)]
pred <- predict(fit,future)
dist <- prophet::predictive_samples(fit,future)[["yhat"]]

Expand Down
Loading

0 comments on commit 7d84440

Please sign in to comment.