mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-07-26 19:52:42 +00:00
Make Python version consistent with R
This commit is contained in:
parent
05effe55ac
commit
a3ae4715bb
2 changed files with 10 additions and 10 deletions
|
|
@ -1264,8 +1264,8 @@ fit.prophet <- function(m, df, ...) {
|
|||
iter = m$mcmc.samples
|
||||
)
|
||||
args <- utils::modifyList(args, list(...))
|
||||
stan.fit <- do.call(rstan::sampling, args)
|
||||
m$params <- rstan::extract(stan.fit)
|
||||
m$stan.fit <- do.call(rstan::sampling, args)
|
||||
m$params <- rstan::extract(m$stan.fit)
|
||||
n.iteration <- length(m$params$k)
|
||||
} else {
|
||||
args <- list(
|
||||
|
|
@ -1277,15 +1277,15 @@ fit.prophet <- function(m, df, ...) {
|
|||
as_vector = FALSE
|
||||
)
|
||||
args <- utils::modifyList(args, list(...))
|
||||
stan.fit <- do.call(rstan::optimizing, args)
|
||||
if (stan.fit$return_code != 0) {
|
||||
m$stan.fit <- do.call(rstan::optimizing, args)
|
||||
if (m$stan.fit$return_code != 0) {
|
||||
message(
|
||||
'Optimization terminated abnormally. Falling back to Newton optimizer.'
|
||||
)
|
||||
args$algorithm = 'Newton'
|
||||
stan.fit <- do.call(rstan::optimizing, args)
|
||||
m$stan.fit <- do.call(rstan::optimizing, args)
|
||||
}
|
||||
m$params <- stan.fit$par
|
||||
m$params <- m$stan.fit$par
|
||||
n.iteration <- 1
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1131,17 +1131,17 @@ class Prophet(object):
|
|||
)
|
||||
args.update(kwargs)
|
||||
try:
|
||||
params = model.optimizing(**args)
|
||||
self.stan_fit = model.optimizing(**args)
|
||||
except RuntimeError:
|
||||
# Fall back on Newton
|
||||
logger.warning(
|
||||
'Optimization terminated abnormally. Falling back to Newton.'
|
||||
)
|
||||
args['algorithm'] = 'Newton'
|
||||
params = model.optimizing(**args)
|
||||
self.stan_fit = model.optimizing(**args)
|
||||
|
||||
for par in params:
|
||||
self.params[par] = params[par].reshape((1, -1))
|
||||
for par in self.stan_fit:
|
||||
self.params[par] = self.stan_fit[par].reshape((1, -1))
|
||||
|
||||
# If no changepoints were requested, replace delta with 0s
|
||||
if len(self.changepoints) == 0:
|
||||
|
|
|
|||
Loading…
Reference in a new issue