Dear All,

my problem case: I want to use the apriori-function to analyze my test data. 
Take a look (the data is attached).

WarenGruppe is a hierarchical higher class for Item. I analyzed with apriori() 
Customer and Item but I want also to start a cross-rule-mining. That means for 
example that one rule could be {Item2, Item4} -> {WG2} and another one could be 
{Item1, Item5} -> {Item2}.
The code is attached. I can just analyze WarenGruppe or Item, but the goal is 
to analyze them booth (like the example).

Has somebody a hint or a reason to realize this "cross-Analysis" in R?

Best regard
Michael
Customer        Item    WarenGruppe
2       item2   WG2     
2       item3   WG3
3       item1   WG1
3       item2   WG2
3       item4   WG2
4       item1   WG1
4       item3   WG3
5       item2   WG2
5       item3   WG3
6       item1   WG1
6       item3   WG3
9       item1   WG1
9       item2   WG2
9       item5   WG3
1       item2   WG2
1       item4   WG2
7       item1   WG1
7       item2   WG2
7       item3   WG3
7       item5   WG3
8       item1   WG1
8       item2   WG2
8       item3   WG3
### Analyse with apriori the table Customer_item

# Data import
item_testdata <- 
read.table("C:/Users/michael.fueg/Documents/R/Daten/Customer_item.txt",header=TRUE)

WarenGruppe=c("WG1","WG2","WG3","WG2","WG3") # We have Item1,...Item5

# Build transaction-class
library(arules)
trans <- as(split(item_testdata[,"Item"], item_testdata[,"Customer"]), 
"transactions")

# Build hierarchical variable
itemInfo(trans)[["WarenGruppe"]] <- WarenGruppe
summary(trans)
inspect(trans)

trans.aggregate <- aggregate(trans, WarenGruppe)
inspect(trans.aggregate)

# Call apriori
rules <- apriori(trans)
inspect(rules)

rules.aggregate <- aggregate(rules, WarenGruppe)
inspect(rules.aggregate)
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to