facebook / facebook/prophet

Problem with custom seasonality prediction

Open
#2,006 0 comments 0 reactions 0 assignees View on GitHub
bug py
Dominant language
Python
Stars
20.4k
Forks
4.6k
Avg merge
19h 52m
Merged PRs (30d)
1

Description

I'm trying to add custom seasonality for weekdays.
![image](https://user-images.githubusercontent.com/43314262/130327341-ffa3bcd6-9be9-4fd3-8661-0295ccff37c7.png)

Got a problem, when predicting new period.

```
TypeError Traceback (most recent call last)
/tmp/ipykernel_22689/1970550396.py in
6 predictor = Predictor()
7 predictor.fit(train_processed)
----> 8 forecast = predictor.predict(process_data_for_model(cutted_data))

/tmp/ipykernel_22689/3512639536.py in predict(self, periods)
17
18 def predict(self, periods: int = WEEK_DURATION) -> pd.DataFrame:
---> 19 future = self.model.make_future_dataframe(periods=periods, freq='h')
20 forecast = self.model.predict(future)
21 return forecast

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/prophet/forecaster.py in make_future_dataframe(self, periods, freq, include_history)
1567 dates = pd.date_range(
1568 start=last_date,
-> 1569 periods=periods + 1, # An extra in case we include start
1570 freq=freq)
1571 dates = dates[dates > last_date] # Drop start if equals last_date

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/ops/common.py in new_method(self, other)
67 other = item_from_zerodim(other)
68
---> 69 return method(self, other)
70
71 return new_method

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/arraylike.py in __add__(self, other)
90 @unpack_zerodim_and_defer("__add__")
91 def __add__(self, other):
---> 92 return self._arith_method(other, operator.add)
93
94 @unpack_zerodim_and_defer("__radd__")

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/frame.py in _arith_method(self, other, op)
6859 self, other = ops.align_method_FRAME(self, other, axis, flex=True, level=None)
6860
-> 6861 new_data = self._dispatch_frame_op(other, op, axis=axis)
6862 return self._construct_result(new_data)
6863

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/frame.py in _dispatch_frame_op(self, right, func, axis)
6886 # i.e. scalar, faster than checking np.ndim(right) == 0
6887 with np.errstate(all="ignore"):
-> 6888 bm = self._mgr.apply(array_op, right=right)
6889 return type(self)(bm)
6890

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/internals/managers.py in apply(self, f, align_keys, ignore_failures, **kwargs)
323 try:
324 if callable(f):
--> 325 applied = b.apply(f, **kwargs)
326 else:
327 applied = getattr(b, f)(**kwargs)

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/internals/blocks.py in apply(self, func, **kwargs)
380 """
381 with np.errstate(all="ignore"):
--> 382 result = func(self.values, **kwargs)
383
384 return self._split_op_result(result)

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/ops/array_ops.py in arithmetic_op(left, right, op)
216 # Timedelta/Timestamp and other custom scalars are included in the check
217 # because numexpr will fail on it, see GH#31457
--> 218 res_values = op(left, right)
219 else:
220 # TODO we should handle EAs consistently and move this check before the if/else

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/ops/common.py in new_method(self, other)
67 other = item_from_zerodim(other)
68
---> 69 return method(self, other)
70
71 return new_method

~/anaconda3/envs/ml-service/lib/python3.8/site-packages/pandas/core/arrays/datetimelike.py in __add__(self, other)
1265 # as is_integer returns True for these
1266 if not is_period_dtype(self.dtype):
-> 1267 raise integer_op_not_supported(self)
1268 result = self._time_shift(other)
1269

TypeError: Addition/subtraction of integers and integer-arrays with DatetimeArray is no longer supported. Instead of adding/subtracting `n`, use `n * obj.freq`
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.