mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-07-19 19:00:52 +00:00
Handle holidays with subdaily data
This commit is contained in:
parent
b93f71540d
commit
ec497ffba8
2 changed files with 12 additions and 1 deletions
|
|
@ -311,7 +311,8 @@ class Prophet(object):
|
|||
# Holds columns of our future matrix.
|
||||
expanded_holidays = defaultdict(lambda: np.zeros(dates.shape[0]))
|
||||
# Makes an index so we can perform `get_loc` below.
|
||||
row_index = pd.DatetimeIndex(dates)
|
||||
# Strip to just dates.
|
||||
row_index = pd.DatetimeIndex(dates.apply(lambda x:x.date()))
|
||||
|
||||
for _ix, row in self.holidays.iterrows():
|
||||
dt = row.ds.date()
|
||||
|
|
|
|||
|
|
@ -326,3 +326,13 @@ class TestProphet(TestCase):
|
|||
m = Prophet()
|
||||
m.fit(DATA)
|
||||
self.assertNotIn('daily', m.seasonalities)
|
||||
|
||||
def test_subdaily_holidays(self):
|
||||
holidays = pd.DataFrame({
|
||||
'ds': pd.to_datetime(['2017-01-02']),
|
||||
'holiday': ['new_years'],
|
||||
})
|
||||
m = Prophet(holidays=holidays)
|
||||
m.fit(DATA2)
|
||||
fcst = m.predict()
|
||||
self.assertEqual(sum(fcst['new_years'] == 0), 575)
|
||||
|
|
|
|||
Loading…
Reference in a new issue