如何预测R中的下一个事件日期

如何预测R中的下一个事件日期,r,R,我有这种格式的数据 lid=structure(list(data_user_create.order = structure(c(1L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 14L, 14L, 14L, 14L,

我有这种格式的数据

lid=structure(list(data_user_create.order = structure(c(1L, 1L, 1L, 
2L, 2L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 
6L, 7L, 7L, 8L, 8L, 8L, 9L, 9L, 9L, 10L, 10L, 10L, 11L, 12L, 
12L, 12L, 12L, 13L, 13L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 
15L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 
19L, 19L, 19L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 
22L, 22L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 25L, 25L, 26L, 26L, 
26L, 26L, 26L, 26L, 27L, 27L, 27L, 28L, 28L, 28L, 29L, 29L, 30L, 
31L, 31L, 31L, 32L, 32L, 32L, 32L, 33L, 33L, 33L, 33L, 33L, 33L, 
33L, 34L, 34L, 34L, 35L, 35L, 35L, 35L), .Label = c("24.08.2017 10:26", 
"24.08.2017 10:27", "24.08.2017 10:28", "24.08.2017 10:29", "24.08.2017 10:30", 
"24.08.2017 10:31", "24.08.2017 10:32", "24.08.2017 10:34", "24.08.2017 10:37", 
"24.08.2017 10:38", "24.08.2017 10:39", "24.08.2017 10:40", "24.08.2017 10:42", 
"24.08.2017 10:43", "24.08.2017 10:44", "24.08.2017 10:45", "24.08.2017 10:46", 
"24.08.2017 10:47", "24.08.2017 10:48", "24.08.2017 10:49", "24.08.2017 10:50", 
"24.08.2017 10:51", "24.08.2017 10:52", "24.08.2017 10:53", "24.08.2017 10:54", 
"24.08.2017 10:55", "24.08.2017 10:56", "24.08.2017 10:57", "24.08.2017 10:58", 
"24.08.2017 10:59", "24.08.2017 11:00", "24.08.2017 11:01", "24.08.2017 11:02", 
"24.08.2017 11:03", "24.08.2017 11:04"), class = "factor"), goods = structure(c(2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Ecoslim", "Hammer of Thor"
), class = "factor"), id_users = 1:119), .Names = c("data_user_create.order", 
"goods", "id_users"), class = "data.frame", row.names = c(NA, 
-119L))
data\u user\u create\u create.order
是指用户在商店中创建订单
货物
是货物的类型
id\u用户
id\u用户不重要吗。 不同的人在同一时间可以订购相同的产品

因此,对于每种商品,我必须以dd-mm-yyy-hh-mm-ss格式创建预测以预测事件日期

我的尝试:

library("forecast")
my_forecast <- function(x){
  model <- arima(x, order = c(1, 1, 1))
  fcast <- forecast(model, 2)
  return(fcast)
}

#applying it as follows

lapply(lid[1], my_forecast)
我认为,
arima
无法将日期作为事件事实进行预测,因为我尝试预测的不是度量var,而是事件将发生的下一个日期(人员创建订单) i、 e.期望输出

date person createon  type of goods
24.08.2017  11:04:02     Ecoslim
24.08.2017  11:04:38      Ecoslim
24.08.2017  11:05:45        Ecoslim 
24.08.2017  11:04:02     pillow
24.08.2017  11:04:38      pillow
24.08.2017  11:05:45        pillow 

如何预测事件的日期?

通常,我会使用回归模型来预测类似的事件

或者,考虑使用时间序列预测。


但是…您的数据集看起来非常稀疏。你有ID,这在ML世界中真的是无用的,再加上日期和商品。逻辑是什么?人类必须知道如何进行预测,然后才能训练机器进行预测(监督学习)。

通常,我会使用回归模型进行类似的预测

或者,考虑使用时间序列预测。


但是…您的数据集看起来非常稀疏。你有ID,这在ML世界中真的是无用的,再加上日期和商品。逻辑是什么?人类必须知道如何进行预测,然后才能训练机器进行预测(监督学习)。

如果能够添加变量,你可以预测下一天的下一个人会创建订单,然后利用那些日子添加到最后的日期并把你的日期作为输出。考虑在一段时间内预测购买,比如在最后一周的两周内,而不是一个确切的日期。也可以考虑格式(我正在看分钟和秒)。@杰西,我可以在OrdError创建二进制变量0吗?1,在人订购之后不购买?这可能对你的问题有不同的概念化。我建议你试着用天来预测变化,而不是实际日期。如果你有一个二进制变量,你可能想看看危险率模型。如果你能够添加一个变量,你可以预测下一天的下一个人创建订单,然后使用那些日子添加到最后的日期,并把你的日期作为输出。考虑在一段时间内预测购买,比如在最后一个订单的两周内,而不是确切的日期。也可以考虑格式(我正在看分钟和秒)。@杰西,我可以在OrdError创建二进制变量0吗?1,在人订购之后不购买?这可能对你的问题有不同的概念化。我建议你试着用天来预测变化,而不是实际日期。如果你有一个二进制变量,你可能想看看危险率模型。
date person createon  type of goods
24.08.2017  11:04:02     Ecoslim
24.08.2017  11:04:38      Ecoslim
24.08.2017  11:05:45        Ecoslim 
24.08.2017  11:04:02     pillow
24.08.2017  11:04:38      pillow
24.08.2017  11:05:45        pillow