Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

バグ修正

  • Loading branch information...
commit 41f21d9e787740e494d16188148932fa6957ba03 1 parent 1a265ed
@mtkn-misty mtkn-misty authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 Chapter6/mails_word_bascket.r
View
20 Chapter6/mails_word_bascket.r
@@ -0,0 +1,20 @@
+library(tm)
+library(arules)
+
+in_data <- read.csv("inbox_txt_data_enron.csv", header=TRUE, sep=",")
+
+terms_list <- as.list(NULL)
+for (i in 1:length(in_data$body)){
+ source <- VectorSource(in_data$body[i])
+ corpus <- Corpus(source)
+ matrix <- TermDocumentMatrix(corpus, control = list(stopwords = TRUE, removeNumbers = TRUE, removePunctuation = TRUE))
+ terms_list <- c(terms_list, list(matrix$dimnames$Terms))
+}
+
+tran <- as(terms_list, "transactions")
+in_ap <- apriori(tran, parameter = list(support=0.03,confidence=0.05, maxlen=3))
+
+inspect(head(sort(subset(in_ap, subset = lhs %pin% "bankruptcy"), by = "support"),n=20))
+inspect(head(sort(subset(in_ap, subset = lhs %pin% "pge"), by = "support"),n=20))
+inspect(head(sort(subset(in_ap, subset = lhs %pin% "crisis"), by = "support"),n=20))
+inspect(head(sort(subset(in_ap, subset = lhs %pin% "edison"), by = "support"),n=20))
Please sign in to comment.
Something went wrong with that request. Please try again.