Beispiel #1
0
def test_custom_date_feature_set():

    ref_dates = [
        pd.to_datetime('20191129', format='%Y%m%d'),
        pd.to_datetime('20200101', format='%Y%m%d')
    ]

    kernel = exponential_kernel(alpha=1.0)

    cfs = CustomDateFeatureSet(ref_dates, kernel)
    sfs = SpecialDateFeatureSet([BLACK_FRIDAY, NEW_YEARS_DAY], kernel)

    date_indices = pd.date_range(start=pd.to_datetime('20191101',
                                                      format='%Y%m%d'),
                                 end=pd.to_datetime('20200131',
                                                    format='%Y%m%d'),
                                 freq='D')

    assert (np.sum(cfs(date_indices) -
                   sfs(date_indices)) == 0), "Features don't match"
Beispiel #2
0
def test_custom_holiday_feature_set():

    custom_holidays = [
        Holiday("New Years Day", month=1, day=1),
        Holiday("Christmas Day", month=12, day=25)
    ]

    kernel = exponential_kernel(alpha=1.0)

    cfs = CustomHolidayFeatureSet(custom_holidays, kernel)
    sfs = SpecialDateFeatureSet([NEW_YEARS_DAY, CHRISTMAS_DAY], kernel)

    date_indices = pd.date_range(start=pd.to_datetime('20191101',
                                                      format='%Y%m%d'),
                                 end=pd.to_datetime('20200131',
                                                    format='%Y%m%d'),
                                 freq='D')

    assert (np.sum(cfs(date_indices) -
                   sfs(date_indices)) == 0), "Features don't match"
Beispiel #3
0
def test_custom_date_feature_set():

    ref_dates = [
        pd.to_datetime("20191129", format="%Y%m%d"),
        pd.to_datetime("20200101", format="%Y%m%d"),
    ]

    kernel = exponential_kernel(alpha=1.0)

    cfs = CustomDateFeatureSet(ref_dates, kernel)
    sfs = SpecialDateFeatureSet([BLACK_FRIDAY, NEW_YEARS_DAY], kernel)

    date_indices = pd.date_range(
        start=pd.to_datetime("20191101", format="%Y%m%d"),
        end=pd.to_datetime("20200131", format="%Y%m%d"),
        freq="D",
    )

    assert (np.sum(
        cfs(date_indices) -
        sfs(date_indices).sum(0, keepdims=True)) == 0), "Features don't match"