Predict trend using the prophet model. Parameters ---------- df: Prediction dataframe. Returns ------- Vector with trend on prediction dates.
(self, df)
| 1368 | return m_t |
| 1369 | |
| 1370 | def predict_trend(self, df): |
| 1371 | """Predict trend using the prophet model. |
| 1372 | |
| 1373 | Parameters |
| 1374 | ---------- |
| 1375 | df: Prediction dataframe. |
| 1376 | |
| 1377 | Returns |
| 1378 | ------- |
| 1379 | Vector with trend on prediction dates. |
| 1380 | """ |
| 1381 | k = np.nanmean(self.params['k']) |
| 1382 | m = np.nanmean(self.params['m']) |
| 1383 | deltas = np.nanmean(self.params['delta'], axis=0) |
| 1384 | |
| 1385 | t = np.array(df['t']) |
| 1386 | if self.growth == 'linear': |
| 1387 | trend = self.piecewise_linear(t, deltas, k, m, self.changepoints_t) |
| 1388 | elif self.growth == 'logistic': |
| 1389 | cap = df['cap_scaled'] |
| 1390 | trend = self.piecewise_logistic( |
| 1391 | t, cap, deltas, k, m, self.changepoints_t) |
| 1392 | elif self.growth == 'flat': |
| 1393 | # constant trend |
| 1394 | trend = self.flat_trend(t, m) |
| 1395 | |
| 1396 | return trend * self.y_scale + df['floor'] |
| 1397 | |
| 1398 | def predict_seasonal_components(self, df): |
| 1399 | """Predict seasonality components, holidays, and added regressors. |
no test coverage detected