forecasting values for each category using Prophet in python

佐手、 提交于 2019-12-03 21:58:45

Separate your dataframe by articletype and then try storing all your predicted values in a dictionary

def get_prediction(df):
    prediction = {}
    df = df.rename(columns={'Date of the document': 'ds','Quantity sold': 'y', 'Article bar code': 'article'})
    list_articles = df2.article.unique()

    for article in list_articles:
        article_df = df2.loc[df2['article'] == article]
        # set the uncertainty interval to 95% (the Prophet default is 80%)
        my_model = Prophet(weekly_seasonality= True, daily_seasonality=True,seasonality_prior_scale=1.0)
        my_model.fit(article_df)
        future_dates = my_model.make_future_dataframe(periods=6, freq='MS')
        forecast = my_model.predict(future_dates)
        prediction[article] = forecast
    return prediction

now the prediction will have forecasts for each type of article.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!