mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-07-03 03:59:00 +00:00
Version bump; test fixes; R build
This commit is contained in:
parent
635ae5a1a6
commit
c9f1ccaa63
12 changed files with 17 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
Package: prophet
|
||||
Title: Automatic Forecasting Procedure
|
||||
Version: 0.3.0.1
|
||||
Version: 0.4
|
||||
Date: 2018-06-13
|
||||
Authors@R: c(
|
||||
person("Sean", "Taylor", email = "sjt@fb.com", role = c("cre", "aut")),
|
||||
|
|
|
|||
|
|
@ -17,4 +17,5 @@ export(predictive_samples)
|
|||
export(prophet)
|
||||
export(prophet_plot_components)
|
||||
import(Rcpp)
|
||||
import(rlang)
|
||||
importFrom(dplyr,"%>%")
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ prophet_copy <- function(m, cutoff = NULL) {
|
|||
weekly.seasonality = FALSE,
|
||||
daily.seasonality = FALSE,
|
||||
holidays = m$holidays,
|
||||
append.holidays = m$append.holidays,
|
||||
seasonality.mode = m$seasonality.mode,
|
||||
seasonality.prior.scale = m$seasonality.prior.scale,
|
||||
changepoint.prior.scale = m$changepoint.prior.scale,
|
||||
|
|
@ -166,6 +165,7 @@ prophet_copy <- function(m, cutoff = NULL) {
|
|||
)
|
||||
m2$extra_regressors <- m$extra_regressors
|
||||
m2$seasonalities <- m$seasonalities
|
||||
m2$country_holidays <- m$country_holidays
|
||||
return(m2)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#' @param country.name Country name (character).
|
||||
#'
|
||||
#' @return A vector of all possible holiday names (unique) of given country.
|
||||
#' @internal
|
||||
#' @keywords internal
|
||||
get_holiday_names <- function(country.name){
|
||||
holidays <- generated_holidays %>%
|
||||
dplyr::filter(country == country.name) %>%
|
||||
|
|
@ -28,7 +28,7 @@ get_holiday_names <- function(country.name){
|
|||
#'
|
||||
#' @return Dataframe with 'ds' and 'holiday', which can directly feed
|
||||
#' to 'holidays' params in Prophet
|
||||
#' @internal
|
||||
#' @keywords internal
|
||||
make_holidays_df <- function(years, country.name){
|
||||
country.holidays = generated_holidays %>%
|
||||
dplyr::filter(country == country.name)
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ globalVariables(c(
|
|||
#' @export
|
||||
#' @importFrom dplyr "%>%"
|
||||
#' @import Rcpp
|
||||
#' @import rlang
|
||||
prophet <- function(df = NULL,
|
||||
growth = 'linear',
|
||||
changepoints = NULL,
|
||||
|
|
@ -1219,7 +1220,7 @@ fit.prophet <- function(m, df, ...) {
|
|||
init = stan_init,
|
||||
iter = m$mcmc.samples
|
||||
)
|
||||
args <- modifyList(args, list(...))
|
||||
args <- utils::modifyList(args, list(...))
|
||||
stan.fit <- do.call(rstan::sampling, args)
|
||||
m$params <- rstan::extract(stan.fit)
|
||||
n.iteration <- length(m$params$k)
|
||||
|
|
@ -1231,7 +1232,7 @@ fit.prophet <- function(m, df, ...) {
|
|||
iter = 1e4,
|
||||
as_vector = FALSE
|
||||
)
|
||||
args <- modifyList(args, list(...))
|
||||
args <- utils::modifyList(args, list(...))
|
||||
stan.fit <- do.call(rstan::optimizing, args)
|
||||
m$params <- stan.fit$par
|
||||
n.iteration <- 1
|
||||
|
|
|
|||
|
|
@ -15,3 +15,4 @@ A vector of all possible holiday names (unique) of given country.
|
|||
\description{
|
||||
Return all possible holiday names of given country
|
||||
}
|
||||
\keyword{internal}
|
||||
|
|
|
|||
|
|
@ -18,3 +18,4 @@ Dataframe with 'ds' and 'holiday', which can directly feed
|
|||
\description{
|
||||
Make dataframe of holidays for given years and countries
|
||||
}
|
||||
\keyword{internal}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ test_that("copy", {
|
|||
weekly.seasonality = c(TRUE, FALSE),
|
||||
daily.seasonality = c(TRUE, FALSE),
|
||||
holidays = c('null', 'insert_dataframe'),
|
||||
append.holidays = c(NULL, 'US'),
|
||||
seasonality.mode = c('additive', 'multiplicative')
|
||||
)
|
||||
products <- expand.grid(inputs)
|
||||
|
|
@ -140,7 +139,6 @@ test_that("copy", {
|
|||
weekly.seasonality = products$weekly.seasonality[i],
|
||||
daily.seasonality = products$daily.seasonality[i],
|
||||
holidays = holidays,
|
||||
append.holidays = products$append.holidays[i],
|
||||
seasonality.prior.scale = 1.1,
|
||||
holidays.prior.scale = 1.1,
|
||||
changepoints.prior.scale = 0.1,
|
||||
|
|
@ -149,13 +147,14 @@ test_that("copy", {
|
|||
uncertainty.samples = 200,
|
||||
fit = FALSE
|
||||
)
|
||||
m1$country_holidays <- 'US'
|
||||
out <- prophet:::setup_dataframe(m1, df, initialize_scales = TRUE)
|
||||
m1 <- out$m
|
||||
m1$history <- out$df
|
||||
m1 <- prophet:::set_auto_seasonalities(m1)
|
||||
m2 <- prophet:::prophet_copy(m1)
|
||||
# Values should be copied correctly
|
||||
args <- c('growth', 'changepoints', 'n.changepoints', 'holidays', 'append.holidays',
|
||||
args <- c('growth', 'changepoints', 'n.changepoints', 'holidays', 'country_holidays',
|
||||
'seasonality.prior.scale', 'holidays.prior.scale',
|
||||
'changepoints.prior.scale', 'mcmc.samples', 'interval.width',
|
||||
'uncertainty.samples', 'seasonality.mode', 'changepoint.range')
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@
|
|||
|
||||
from fbprophet.forecaster import Prophet
|
||||
|
||||
__version__ = '0.4.dev'
|
||||
__version__ = '0.4'
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ def prophet_copy(m, cutoff=None):
|
|||
weekly_seasonality=False,
|
||||
daily_seasonality=False,
|
||||
holidays=m.holidays,
|
||||
append_holidays=m.append_holidays,
|
||||
seasonality_mode=m.seasonality_mode,
|
||||
seasonality_prior_scale=m.seasonality_prior_scale,
|
||||
changepoint_prior_scale=m.changepoint_prior_scale,
|
||||
|
|
@ -170,6 +169,7 @@ def prophet_copy(m, cutoff=None):
|
|||
)
|
||||
m2.extra_regressors = deepcopy(m.extra_regressors)
|
||||
m2.seasonalities = deepcopy(m.seasonalities)
|
||||
m2.country_holidays = deepcopy(m.country_holidays)
|
||||
return m2
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,6 @@ class TestDiagnostics(TestCase):
|
|||
# These values are created except for its default values
|
||||
holiday = pd.DataFrame(
|
||||
{'ds': pd.to_datetime(['2016-12-25']), 'holiday': ['x']})
|
||||
append_holidays = 'US'
|
||||
products = itertools.product(
|
||||
['linear', 'logistic'], # growth
|
||||
[None, pd.to_datetime(['2016-12-25'])], # changepoints
|
||||
|
|
@ -151,7 +150,6 @@ class TestDiagnostics(TestCase):
|
|||
[True, False], # weekly_seasonality
|
||||
[True, False], # daily_seasonality
|
||||
[None, holiday], # holidays
|
||||
[None, append_holidays], # append_holidays
|
||||
['additive', 'multiplicative'], # seasonality_mode
|
||||
[1.1], # seasonality_prior_scale
|
||||
[1.1], # holidays_prior_scale
|
||||
|
|
@ -163,6 +161,7 @@ class TestDiagnostics(TestCase):
|
|||
# Values should be copied correctly
|
||||
for product in products:
|
||||
m1 = Prophet(*product)
|
||||
m1.country_holidays = 'US'
|
||||
m1.history = m1.setup_dataframe(
|
||||
df.copy(), initialize_scales=True)
|
||||
m1.set_auto_seasonalities()
|
||||
|
|
@ -184,7 +183,7 @@ class TestDiagnostics(TestCase):
|
|||
self.assertEqual(m1.holidays, m2.holidays)
|
||||
else:
|
||||
self.assertTrue((m1.holidays == m2.holidays).values.all())
|
||||
self.assertEqual(m1.append_holidays, m2.append_holidays)
|
||||
self.assertEqual(m1.country_holidays, m2.country_holidays)
|
||||
self.assertEqual(m1.seasonality_mode, m2.seasonality_mode)
|
||||
self.assertEqual(m1.seasonality_prior_scale, m2.seasonality_prior_scale)
|
||||
self.assertEqual(m1.changepoint_prior_scale, m2.changepoint_prior_scale)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ with open('requirements.txt', 'r') as f:
|
|||
|
||||
setup(
|
||||
name='fbprophet',
|
||||
version='0.3.post2',
|
||||
version='0.4',
|
||||
description='Automatic Forecasting Procedure',
|
||||
url='https://facebook.github.io/prophet/',
|
||||
author='Sean J. Taylor <sjt@fb.com>, Ben Letham <bletham@fb.com>',
|
||||
|
|
|
|||
Loading…
Reference in a new issue