分隔数据框articletype
,然后尝试将所有预测值存储在字典中
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
现在,该预测将具有每种文章的预测。