Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add ano more measure of interest in the arules package

Tags:

arules

I would like to add two additional measures as a results of the "inspect" function in arules package. They are Kulczynski and imbalance ratio. Would you help me with info, where to find the code of inspect function and how to modify it.

Thanks

like image 948
Georgi Tsonev Avatar asked Sep 11 '15 08:09

Georgi Tsonev


1 Answers

All you need to do is to add additional columns to the quality data.frame. Inspect will automatically pick those up. Here is the example from ? interestMeasure:

data("Income")
rules <- apriori(Income)

## calculate a single measure and add it to the quality slot
quality(rules) <- cbind(quality(rules), 
  hyperConfidence = interestMeasure(rules, method = "hyperConfidence",
     transactions = Income))

inspect(head(sort(rules, by = "hyperConfidence")))

  lhs                                 rhs                                support confidence     lift hyperConfidence
1 {ethnic classification=hispanic} => {education=no college graduate} 0.1096568  0.8636884 1.224731               1
2 {dual incomes=no}                => {marital status=married}        0.1400524  0.9441176 2.447871               1
3 {occupation=student}             => {marital status=single}         0.1449971  0.8838652 2.160490               1
4 {occupation=student}             => {age=14-34}                     0.1592496  0.9707447 1.658345               1
5 {occupation=student}             => {dual incomes=not married}      0.1535777  0.9361702 1.564683               1
6 {occupation=student}             => {income=$0-$40,000}             0.1381617  0.8421986 1.353027               1
like image 129
Michael Hahsler Avatar answered Sep 29 '22 14:09

Michael Hahsler