prophet icon indicating copy to clipboard operation
prophet copied to clipboard

forecaster.preprocess() may introduce unwanted behavior for NaN history values in 1.1.5

Open imad24 opened this issue 2 years ago • 2 comments

I have noticed that the changes made to this line may introduce unwanted behavior in the future dataframe:

https://github.com/facebook/prophet/blob/c00f6a2d72229faa6acee8292bc01e14f16f599c/python/prophet/forecaster.py#L1133

This will make make_future_dataframe() ignore the dates with NaN values in the history, considering

history = df[df['y'].notnull()].copy()

in the versions prior to 1.1.5 (for reference):

self.history_dates = pd.to_datetime(pd.Series(df['ds'].unique(), name='ds')).sort_values()

Notice that the dataframe df['ds'].unique()is used instead of the not null history['ds'].unique()

imad24 avatar Oct 25 '23 14:10 imad24

Thanks for noticing this! It makes sense that we'd want predictions for missing y dates in the history. More than happy to review a PR if you have time to raise a bug fix, otherwise I'll try get to it in the next couple of weeks.

tcuongd avatar Oct 26 '23 09:10 tcuongd

Hey @tcuongd, I've created the PR to fix the bug and added a test for make_future_dataset(,,include_history=True)

imad24 avatar Nov 20 '23 16:11 imad24