规则中read_baskets中的警告消息R

时间:2020-02-03 06:40:26

标签: r data-mining

我正在尝试使用R使用我的数据从这篇文章中重现序列挖掘示例。 https://blog.revolutionanalytics.com/2019/02/sequential-pattern-mining-in-r.html 如果有人想重现示例,这是我的数据集。 https://drive.google.com/file/d/1aqyldwfJm0w--E8VG5oOWHxPRMjPwapG/view?usp=sharing

输入

# Start time of data to be considered
start_month <- "2012-01-01"
# Create list of  services by customer ID and CleanMonth (formatted dates)
trans_sequence <- transactions %>%
  group_by(TNST, Fdate) %>%
  summarize(
    SIZE = n(),
    TC = paste(as.character(TC), collapse = ';')
  )
# Make event and sequence IDs into factors
elapsed_months <- function(end_date, start_date) {
  ed <- as.POSIXlt(end_date)
  sd <- as.POSIXlt(start_date)
  12 * (ed$year - sd$year) + (ed$mon - sd$mon)
}
trans_sequence$eventID <- elapsed_months(trans_sequence$Fdate, start_month)
trans_sequence = trans_sequence[,c(1,5,3,4)]
names(trans_sequence) = c("sequenceID", "eventID", "SIZE", "items")
trans_sequence <- data.frame(lapply(trans_sequence, as.factor))
trans_sequence <- trans_sequence[order(trans_sequence$sequenceID, trans_sequence$eventID),]
# Convert to transaction matrix data type
write.table(trans_sequence, "mytxtout.csv", sep=";", row.names = FALSE, col.names = FALSE, quote = FALSE)
trans_matrix <- read_baskets("mytxtout.csv", sep = ";", info = c("sequenceID","eventID","SIZE"))

我得到错误

Warning message in read_baskets("mytxtout.csv", sep = ";", info = c("sequenceID", :
“eventID not positive”

尽管生成了csv文件,但实际上我无法应用SPADE,因为下一步只需要正的eventID即可 我是R的新秀,请先感谢

0 个答案:

没有答案
相关问题