This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
results <- vector(mode = 'numeric', length = nrow(prophetGrid)) | |
# Search best parameters | |
for (i in seq_len(nrow(prophetGrid))) { | |
parameters <- prophetGrid[i, ] | |
if (parameters$growth == 'logistic') {train$cap <- parameters$capacity} | |
m <- prophet(train, growth = parameters$growth, holidays = holidays, | |
seasonality.prior.scale = parameters$seasonality_prior_scale, | |
changepoint.prior.scale = parameters$changepoint_prior_scale, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Search grid | |
prophetGrid <- expand.grid(changepoint_prior_scale = c(0.05, 0.5, 0.001), | |
seasonality_prior_scale = c(100, 10, 1), | |
holidays_prior_scale = c(100, 10, 1), | |
capacity = c(6043, 6500, 7000, 8000), | |
growth = 'logistic') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
holidays <- filter(bikes, holiday == 1) %>% | |
select(datetime) %>% | |
distinct() | |
holidays$holiday = c('Martin Luther King', 'Emancipation Day', 'Independence Day', | |
'Labor Day', 'Columbus Day', 'Veterans Day', 'New Year', | |
'Martin Luther King', 'Emancipation Day', 'Independence Day', | |
'Labor Day', 'Columbus Day', 'Veterans Day') | |
names(holidays) <- c('ds', 'holiday') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Libraries | |
library(tidyverse) | |
library(lubridate) | |
library(prophet) | |
library(forecast) | |
# Read data | |
bikes <- read_csv('bikes.csv') %>% | |
mutate(datetime = date(datetime)) |
NewerOlder