【问题标题】:Time Series Analysis for Individual Customers个人客户的时间序列分析
【发布时间】:2018-06-21 07:19:04
【问题描述】:

我是 1000 位客户在过去 2 年的购买次数的时间序列数据。我能够为整个数据集构建时间序列预测模型。但是现在我想为这 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

【问题讨论】:

  • 您是否尝试过使用 group_by 获取所有客户,然后将您的时间序列预测模型应用于 customer='Customer 1 or 2 etc' 的每个子数据框?
  • 是的,我做到了。但效率不高,而且我必须修改每个时间序列的参数
  • 你能澄清你的要求吗?您是在寻找一种以特定方式组织数据的方法,还是寻找通用模型的建议(更适合CrossValidated 的问题)?
  • 我要求一种设计通用模型的方法

标签: python pandas time-series forecasting arima


【解决方案1】:

首先,创建一个函数 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方法并行处理客户:

pool.map(Forecast,np.unique(df['customer_id'])) 最后连接结果

【讨论】:

  • 我已经实现了类似的东西,但没有尝试多处理方法。马上试试
猜你喜欢
  • 2020-11-16
  • 2011-12-26
  • 2020-06-03
  • 2013-10-20
  • 2014-07-10
  • 1970-01-01
  • 1970-01-01
  • 2013-09-08
  • 2018-03-11
相关资源
最近更新 更多