我为1000名客户提供了关于他们在过去两年中购买数量的时间序列数据。我能够为整个数据集构建时间序列预测模型。但现在我想为1000个客户中的每个人建立预测模型,解决这个问题的最佳方法是什么。
PS:我能想到的一种方法是迭代1000个客户中的每个客户,并为每个客户建立单独的模型。但从长远来看,这不是一个可行的解决方案。
有人能帮我找到更好的方法吗?
示例数据:
custmore_id,date,count_order
1,2015-06,24
1,2015-07,26
...
1,2017-08,320
2,2015-06,12
2,2015-07,32
..
2,2017-08,500发布于 2018-01-12 17:37:46
首先创建一个函数池,然后使用多进程库的def Forecast(costumer_id,prediction_date): df_customer = df[df['customer_id']==customer_id] do forecasting on df_customer return forecast for customer and prediction_date方法并行处理客户:
pool.map(Forecast,np.unique(df['customer_id']))并最终连接结果
https://stackoverflow.com/questions/48215909
复制相似问题