MCPcopy
hub / github.com/facebook/prophet / predict_trend

Method predict_trend

python/prophet/forecaster.py:1370–1396  ·  view source on GitHub ↗

Predict trend using the prophet model. Parameters ---------- df: Prediction dataframe. Returns ------- Vector with trend on prediction dates.

(self, df)

Source from the content-addressed store, hash-verified

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.

Callers 1

predictMethod · 0.95

Calls 3

piecewise_linearMethod · 0.95
piecewise_logisticMethod · 0.95
flat_trendMethod · 0.95

Tested by

no test coverage detected