gpt4 book ai didi

python - 预测,(找到正确的模型)

转载 作者:行者123 更新时间:2023-11-30 09:05:57 26 4
gpt4 key购买 nike

使用 Python,我尝试使用历史销售数据来预测产品的 future 销售数量。我还试图预测各组产品的这些计数。

例如,我的专栏如下所示:

Date Sales_count Department Item Color

8/1/2018, 50, Homegoods, Hats, Red_hat

如果我想构建一个模型,使用历史数据(时间)预测每个部门/商品/颜色组合的 sales_count,最好使用什么模型?

如果我对销售额进行时间线性回归,我如何解释各种类别?我可以将它们分组吗?

我是否会使用多线性回归,将各种类别视为自变量?

最佳答案

我在Python预测中遇到的最好方法是使用statsmodel库中的SARIMAX(带有外生变量的季节性自动回归综合移动平均线)模型。这是 SARIMAX using python 中非常好的教程的链接另外,如果您能够根据部门/项目颜色组合对数据框进行分组,则可以将它们放入循环中并应用相同的模型。也许您可以为每个独特的组合创建一个键,并且对于每个键条件,您可以预测销售额。例如,

df=pd.read_csv('your_file.csv')
df['key']=df['Department']+'_'+df['Item']+'_'+df['Color']
for key in df['key'].unique():
temp=df.loc[df['key']==key]#filtering only the specific group
temp=temp.groupby('Date')['Sales_count'].sum().reset_index()
#aggregating the sum of sales in that date. Ignore if not required.
#write the forecasting code here from the tutorial

关于python - 预测,(找到正确的模型),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51958471/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com