Predict seasonality components, holidays, and added regressors. Parameters ---------- df: Prediction dataframe. Returns ------- Dataframe with seasonal components.
(self, df)
| 1396 | return trend * self.y_scale + df['floor'] |
| 1397 | |
| 1398 | def predict_seasonal_components(self, df): |
| 1399 | """Predict seasonality components, holidays, and added regressors. |
| 1400 | |
| 1401 | Parameters |
| 1402 | ---------- |
| 1403 | df: Prediction dataframe. |
| 1404 | |
| 1405 | Returns |
| 1406 | ------- |
| 1407 | Dataframe with seasonal components. |
| 1408 | """ |
| 1409 | seasonal_features, _, component_cols, _ = ( |
| 1410 | self.make_all_seasonality_features(df) |
| 1411 | ) |
| 1412 | if self.uncertainty_samples: |
| 1413 | lower_p = 100 * (1.0 - self.interval_width) / 2 |
| 1414 | upper_p = 100 * (1.0 + self.interval_width) / 2 |
| 1415 | |
| 1416 | X = seasonal_features.values |
| 1417 | data = {} |
| 1418 | for component in component_cols.columns: |
| 1419 | beta_c = self.params['beta'] * component_cols[component].values |
| 1420 | |
| 1421 | comp = np.matmul(X, beta_c.transpose()) |
| 1422 | if component in self.component_modes['additive']: |
| 1423 | comp *= self.y_scale |
| 1424 | data[component] = np.nanmean(comp, axis=1) |
| 1425 | if self.uncertainty_samples: |
| 1426 | data[component + '_lower'] = self.percentile( |
| 1427 | comp, lower_p, axis=1, |
| 1428 | ) |
| 1429 | data[component + '_upper'] = self.percentile( |
| 1430 | comp, upper_p, axis=1, |
| 1431 | ) |
| 1432 | return pd.DataFrame(data) |
| 1433 | |
| 1434 | def predict_uncertainty(self, df: pd.DataFrame, vectorized: bool) -> pd.DataFrame: |
| 1435 | """Prediction intervals for yhat and trend. |
no test coverage detected