"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "R/tests/testthat/test_prophet.R" between
prophet-0.7.tar.gz and prophet-1.0.tar.gz

About: Prophet is a tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.

test_prophet.R  (prophet-0.7):test_prophet.R  (prophet-1.0)
skipping to change at line 240 skipping to change at line 240
out <- prophet:::setup_dataframe(m, history, initialize_scales = TRUE) out <- prophet:::setup_dataframe(m, history, initialize_scales = TRUE)
m <- out$m m <- out$m
history <- out$df history <- out$df
params <- prophet:::linear_growth_init(history) params <- prophet:::linear_growth_init(history)
expect_equal(params[1], 0.3055671, tolerance = 1e-6) expect_equal(params[1], 0.3055671, tolerance = 1e-6)
expect_equal(params[2], 0.5307511, tolerance = 1e-6) expect_equal(params[2], 0.5307511, tolerance = 1e-6)
params <- prophet:::logistic_growth_init(history) params <- prophet:::logistic_growth_init(history)
expect_equal(params[1], 1.507925, tolerance = 1e-6) expect_equal(params[1], 1.507925, tolerance = 1e-6)
expect_equal(params[2], -0.08167497, tolerance = 1e-6) expect_equal(params[2], -0.08167497, tolerance = 1e-6)
params <- prophet:::flat_growth_init(history)
expect_equal(params[1], 0, tolerance = 1e-6)
expect_equal(params[2], 0.49335657, tolerance = 1e-6)
}) })
test_that("piecewise_linear", { test_that("piecewise_linear", {
t <- seq(0, 10) t <- seq(0, 10)
m <- 0 m <- 0
k <- 1.0 k <- 1.0
deltas <- c(0.5) deltas <- c(0.5)
changepoint.ts <- c(5) changepoint.ts <- c(5)
y <- prophet:::piecewise_linear(t, deltas, k, m, changepoint.ts) y <- prophet:::piecewise_linear(t, deltas, k, m, changepoint.ts)
skipping to change at line 282 skipping to change at line 286
9.984988, 9.996646, 9.999252, 9.999833, 9.999963) 9.984988, 9.996646, 9.999252, 9.999833, 9.999963)
expect_equal(y, y.true, tolerance = 1e-6) expect_equal(y, y.true, tolerance = 1e-6)
t <- t[8:length(t)] t <- t[8:length(t)]
y.true <- y.true[8:length(y.true)] y.true <- y.true[8:length(y.true)]
cap <- cap[8:length(cap)] cap <- cap[8:length(cap)]
y <- prophet:::piecewise_logistic(t, cap, deltas, k, m, changepoint.ts) y <- prophet:::piecewise_logistic(t, cap, deltas, k, m, changepoint.ts)
expect_equal(y, y.true, tolerance = 1e-6) expect_equal(y, y.true, tolerance = 1e-6)
}) })
test_that("flat_trend", {
t <- seq(0, 10)
m <- 0.5
y = prophet:::flat_trend(t, m)
y.true <- rep(0.5, length(t))
expect_equal(y, y.true, tolerance = 1e-6)
t <- t[8:length(t)]
y = prophet:::flat_trend(t, m)
y.true <- y.true[8:length(y.true)]
expect_equal(y, y.true, tolerance = 1e-6)
})
test_that("holidays", { test_that("holidays", {
holidays <- data.frame(ds = c('2016-12-25'), holidays <- data.frame(ds = c('2016-12-25'),
holiday = c('xmas'), holiday = c('xmas'),
lower_window = c(-1), lower_window = c(-1),
upper_window = c(0)) upper_window = c(0))
df <- data.frame( df <- data.frame(
ds = seq(prophet:::set_date('2016-12-20'), ds = seq(prophet:::set_date('2016-12-20'),
prophet:::set_date('2016-12-31'), by='d')) prophet:::set_date('2016-12-31'), by='d'))
m <- prophet(train, holidays = holidays, fit = FALSE) m <- prophet(train, holidays = holidays, fit = FALSE)
out <- prophet:::make_holiday_features(m, df$ds, m$holidays) out <- prophet:::make_holiday_features(m, df$ds, m$holidays)
 End of changes. 3 change blocks. 
1 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)