Add an additional regressor to be used for fitting and predicting. The dataframe passed to `fit` and `predict` will have a column with the specified name to be used as a regressor. When standardize='auto', the regressor will be standardized unless it is binary. The regressio
(self, name, prior_scale=None, standardize='auto',
mode=None)
| 629 | return holiday_features, prior_scale_list, holiday_names |
| 630 | |
| 631 | def add_regressor(self, name, prior_scale=None, standardize='auto', |
| 632 | mode=None): |
| 633 | """Add an additional regressor to be used for fitting and predicting. |
| 634 | |
| 635 | The dataframe passed to `fit` and `predict` will have a column with the |
| 636 | specified name to be used as a regressor. When standardize='auto', the |
| 637 | regressor will be standardized unless it is binary. The regression |
| 638 | coefficient is given a prior with the specified scale parameter. |
| 639 | Decreasing the prior scale will add additional regularization. If no |
| 640 | prior scale is provided, self.holidays_prior_scale will be used. |
| 641 | Mode can be specified as either 'additive' or 'multiplicative'. If not |
| 642 | specified, self.seasonality_mode will be used. 'additive' means the |
| 643 | effect of the regressor will be added to the trend, 'multiplicative' |
| 644 | means it will multiply the trend. |
| 645 | |
| 646 | Parameters |
| 647 | ---------- |
| 648 | name: string name of the regressor. |
| 649 | prior_scale: optional float scale for the normal prior. If not |
| 650 | provided, self.holidays_prior_scale will be used. |
| 651 | standardize: optional, specify whether this regressor will be |
| 652 | standardized prior to fitting. Can be 'auto' (standardize if not |
| 653 | binary), True, or False. |
| 654 | mode: optional, 'additive' or 'multiplicative'. Defaults to |
| 655 | self.seasonality_mode. |
| 656 | |
| 657 | Returns |
| 658 | ------- |
| 659 | The prophet object. |
| 660 | """ |
| 661 | if self.history is not None: |
| 662 | raise Exception( |
| 663 | "Regressors must be added prior to model fitting.") |
| 664 | self.validate_column_name(name, check_regressors=False) |
| 665 | if prior_scale is None: |
| 666 | prior_scale = float(self.holidays_prior_scale) |
| 667 | if mode is None: |
| 668 | mode = self.seasonality_mode |
| 669 | if prior_scale <= 0: |
| 670 | raise ValueError('Prior scale must be > 0') |
| 671 | if mode not in ['additive', 'multiplicative']: |
| 672 | raise ValueError("mode must be 'additive' or 'multiplicative'") |
| 673 | self.extra_regressors[name] = { |
| 674 | 'prior_scale': prior_scale, |
| 675 | 'standardize': standardize, |
| 676 | 'mu': 0., |
| 677 | 'std': 1., |
| 678 | 'mode': mode, |
| 679 | } |
| 680 | return self |
| 681 | |
| 682 | def add_seasonality(self, name, period, fourier_order, prior_scale=None, |
| 683 | mode=None, condition_name=None): |