From 91917df8f0defd5393ba908b647c9c9da620d7b8 Mon Sep 17 00:00:00 2001 From: Ben Letham Date: Mon, 3 Dec 2018 14:25:28 -0800 Subject: [PATCH] Handle parameter shaping with MCMC and one changepoint (#608) --- python/fbprophet/forecaster.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/fbprophet/forecaster.py b/python/fbprophet/forecaster.py index b2e392b..d2092ba 100644 --- a/python/fbprophet/forecaster.py +++ b/python/fbprophet/forecaster.py @@ -1092,7 +1092,6 @@ class Prophet(object): ) for par in stan_fit.model_pars: self.params[par] = stan_fit[par] - else: try: params = model.optimizing( @@ -1103,8 +1102,12 @@ class Prophet(object): dat, init=stan_init, iter=1e4, algorithm='Newton', **kwargs ) - for par in params: - self.params[par] = params[par].reshape((1, -1)) + self.params = params + + # Reshape all parameters to matrix shape + for p, v in self.params.items(): + if len(v.shape) == 1: + self.params[p] = v.reshape((-1, 1)) # If no changepoints were requested, replace delta with 0s if len(self.changepoints) == 0: