def test_prophet(daily_data): """Tests prophet estimator.""" model = OneByOneEstimator(estimator="ProphetEstimator", forecast_horizon=3, estimator_map=[1, 2], coverage=None) train_df = daily_data["train_df"] model.fit(train_df, time_col=cst.TIME_COL, value_col=cst.VALUE_COL)
def test_forecast_one_by_one_not_activated(daily_data): """Tests forecast one-by-one is not activated when no parameter depends on forecast horizon. """ model = OneByOneEstimator(estimator="SimpleSilverkiteEstimator", forecast_horizon=3, estimator_map=[1, 2], estimator_params={ "autoreg_dict": None, "yearly_seasonality": 2, "feature_sets_enabled": False }) train_df = daily_data["train_df"] model.fit(train_df, time_col=cst.TIME_COL, value_col=cst.VALUE_COL) assert len(model.estimators) == 1 assert model.estimator_map_list == [3] assert model.pred_indices is None
def __apply_forecast_one_by_one_to_pipeline_parameters(self): """If forecast_one_by_one is activated, 1. replaces the estimator with ``OneByOneEstimator`` in pipeline. 2. Adds one by one estimator's parameters to ``hyperparameter_grid``. """ if self.config.forecast_one_by_one not in (None, False): pipeline = get_basic_pipeline( estimator=OneByOneEstimator( estimator=self.template.estimator.__class__.__name__, forecast_horizon=self.config.forecast_horizon), score_func=self.template.score_func, score_func_greater_is_better=self.template. score_func_greater_is_better, agg_periods=self.template.config.evaluation_metric_param. agg_periods, agg_func=self.template.config.evaluation_metric_param.agg_func, relative_error_tolerance=self.template.config. evaluation_metric_param.relative_error_tolerance, coverage=self.template.config.coverage, null_model_params=self.template.config.evaluation_metric_param. null_model_params, regressor_cols=self.template.regressor_cols) self.pipeline_params["pipeline"] = pipeline if isinstance(self.pipeline_params["hyperparameter_grid"], list): for i in range(len( self.pipeline_params["hyperparameter_grid"])): self.pipeline_params["hyperparameter_grid"][i][ "estimator__forecast_horizon"] = [ self.config.forecast_horizon ] self.pipeline_params["hyperparameter_grid"][i][ "estimator__estimator_map"] = [ self.config.forecast_one_by_one ] else: self.pipeline_params["hyperparameter_grid"][ "estimator__forecast_horizon"] = [ self.config.forecast_horizon ] self.pipeline_params["hyperparameter_grid"][ "estimator__estimator_map"] = [ self.config.forecast_one_by_one ]