コード例 #1
0
def test_prophet_adjust_holidays_related_features(
    X_with_holidays,
    extra_holidays,
    expected_result_prophet_adjust_holidays_related_features,
):

    prophet = ProphetWrapper(extra_holidays=extra_holidays)
    prophet.model = prophet._init_tsmodel(Prophet)
    prophet._adjust_holidays(X_with_holidays)
    holidays = prophet.model.holidays
    assert_frame_equal(holidays, expected_result_prophet_adjust_holidays_related_features)
コード例 #2
0
def test_prophet_adjust_holidays(X_with_holidays, extra_holidays):

    prophet = ProphetWrapper(extra_holidays=extra_holidays)
    prophet.model = prophet._init_tsmodel(Prophet)
    X = prophet._adjust_holidays(X_with_holidays)
    holidays = prophet.model.holidays

    assert_frame_equal(X, X_with_holidays.drop(columns="_holiday_DE"))
    assert isinstance(holidays, pd.DataFrame)
    assert "ds" in holidays.columns.tolist()
    assert "holiday" in holidays.columns.tolist()

    assert set(holidays.columns) == set(
        ["ds", "holiday", "lower_window", "upper_window", "prior_scale"])
    if extra_holidays:
        for holiday_name, holiday_params in extra_holidays.items():
            for params_key, params_values in holiday_params.items():
                assert (holidays.loc[holidays["holiday"] == holiday_name +
                                     "_DE",
                                     params_key].values[0] == params_values)
コード例 #3
0
def test_prophet_adjust_holidays(X_with_holidays, extra_holidays):

    prophet = ProphetWrapper(extra_holidays=extra_holidays)
    prophet.model = prophet._init_tsmodel(Prophet)
    X = prophet._adjust_holidays(X_with_holidays)
    holidays = prophet.model.holidays
    assert_frame_equal(X, X_with_holidays.drop(columns="holiday"))
    assert isinstance(holidays, pd.DataFrame)
    assert "ds" in holidays.columns.tolist()
    assert "holiday" in holidays.columns.tolist()
    max_holiday_len = (
        0
        if prophet.extra_holidays is None
        else max([len(prophet.extra_holidays[key]) for key in prophet.extra_holidays.keys()], default=0,)
    )
    assert holidays.shape[1] == len(["ds", "holiday"]) + max_holiday_len
    if extra_holidays:
        for holiday_name, holiday_params in extra_holidays.items():
            for params_key, params_values in holiday_params.items():
                assert (
                    holidays.loc[holidays["holiday"] == holiday_name, params_key].values[0] == params_values
                )