R: Calculate Additional Interest Measures

interestMeasure {arules} | R Documentation

## Calculate Additional Interest Measures

### Description

Provides the generic function `interestMeasure` and the needed S4 method to calculate various additional interest measures for existing sets of itemsets or rules. A searchable list of definitions, equations and references for all available interest measures can be found here: A Probabilistic Comparison of Commonly Used Interest Measures for Association Rules (Hahsler, 2015).

### Usage

    interestMeasure(x, measure, transactions = NULL, reuse = TRUE, ...)

### Arguments

`x` | a set of itemsets or rules.
`measure` | name or vector of names of the desired interest measures (see details for available measures). If measure is missing then all available measures are calculated.
`transactions` | the transaction data set used to mine the associations or a set of different transactions to calculate interest measures from (Note: you need to set `reuse=FALSE` in the later case).
`reuse` | logical indicating if information in quality slot should be reuse for calculating the measures. This speeds up the process significantly since only very little (or no) transaction counting is necessary if support, confidence and lift are already available. Use `reuse=FALSE` to force counting (might be very slow but is necessary if you use a different set of transactions than was used for mining).
`...` | further arguments for the measure calculation.

### Details

The following measures are implemented for itemsets X:

"allConfidence" (Omiencinski, 2003)

  Is defined on itemsets as the minimum confidence of all possible rule generated from the itemset. See details: All-Confidence

  Range: [0, 1]

"crossSupportRatio", cross-support ratio (Xiong et al., 2003)

  Defined on itemsets as the ratio of the support of the least frequent item to the support of the most frequent item. Cross-support patterns have a ratio smaller than a set threshold. Normally many found patterns are cross-support patterns which contain frequent as well as rare items. Such patterns often tend to be spurious. See details: Cross-Support Ratio

  Range: [0, 1]

"lift"

  Lift is typically only defined for rules. In a similar way, we use the probability (support) of the itemset over the product of the probabilities of all items in the itemset, i.e., supp(X)/(supp(x_1) supp(x_2) ... supp(x_n)).

  Range: [0, Inf] (1 indicated independence)

"support", supp (Agrawal et al., 1996)

  Support is an estimate of P(X), a measure of generality of the itemset. It is estimated by the number of transactions that contain the itemset over the total number of transactions in the data set. See details: Support

  Range: [0, 1]

"count"

  Absolute support count of the itemset, i.e., the number of transactions that contain the itemset. See details: Support Count

  Range: [0, ∞]

The following measures are implemented for rules of the form X -> Y:

"addedValue", added Value, AV, Pavillon index, centered confidence (Tan et al., 2002)

  Defined as the rule confidence minus the rules support. See details: Added Value

  Range: [-.5, 1]

"boost", confidence boost (Balcazar, 2013)

  Confidence boost is the ratio of the confidence of a rule to the confidence of any more general rule (i.e., a rule with the same consequent but one or more items removed in the LHS). Values larger than 1 mean the new rule boosts the confidence compared to the best, more general rule. The measure is related to the improvement measure. See details: Confidence boost

  Range: [0, Inf]

"chiSquared", X^2 statistic (Liu et al., 1999)

  The chi-squared statistic to test for independence between the lhs and rhs of the rule. The critical value of the chi-squared distribution with 1 degree of freedom (2x2 contingency table) at alpha=0.05 is 3.84; higher chi-squared values indicate that the lhs and the rhs are not independent. See details: Chi-Squared statistic

  Note that the contingency table is likely to have cells with low expected values and that thus Fisher's Exact Test might be more appropriate (see below).

  Called with `significance=TRUE`, the p-value of the test for independence is returned instead of the chi-squared statistic. For p-values, substitutes effects can be tested using the parameter `complements = FALSE`. Correction for multiple comparisons can be done using `p.adjust`.

  Range: [0, Inf] or p-value scale

"certainty", certainty factor, CF, Loevinger (Berzal et al., 2002)

  The certainty factor is a measure of variation of the probability that Y is in a transaction when only considering transactions with X. An increasing CF means a decrease of the probability that Y is not in a transaction that X is in. Negative CFs have a similar interpretation. See details: Certainty Factor

  Range: [-1, 1] (0 indicates independence)

"collectiveStrength"

  Collective strength (S).

  Collective strength gives 0 for perfectly negative correlated items, infinity for perfectly positive correlated items, and 1 if the items co-occur as expected under independence. See details: Collective Strength

  Range: [0, Inf]

"confidence", Strength, conf (Agrawal et al., 1996)

  Confidence is a measure of rule validity. Rule confidence is an estimate of P(Y|X). See details: Confidence

  Range [0, 1]

"conviction" (Brin et al. 1997)

  Conviction was developed as an alternative to lift that also incorporates the direction of the rule. See details: Conviction

  Range: [0, Inf] (1 indicates unrelated items)

"cosine" (Tan et al., 2004)

  A measure if correlation between the items in X and Y. See details: Cosine

  Range: [0, 1](.5 indicates no correlation)

"count"

  Absolute support count of the rule, i.e., the number of transactions that contain all items in the rule. See details: Support Count

  Range: [0, ∞]

"coverage", cover, LHS-support

  It measures the probability that a rule applies to a randomly selected transaction. It is estimated by the proportion of transactions that contain the antecedent (LHS) of the rule. Therefore, coverage is sometimes called antecedent support or LHS support. See details: Coverage

  Range: [0, 1]

"confirmedConfidence", descriptive confirmed confidence (Kodratoff, 1999)

  How much higher is the confidence of a rule compared to the confidence of the rule X -> !Y. See details: Descriptive Confirmed Confidence

  Range: [-1, 1]

"casualConfidence", casual confidence (Kodratoff, 1999)

  Confidence reinforced by the confidence of the rule !X -> !Y. See details: Casual Confidence

  Range: [0, 1]

"casualSupport", casual support (Kodratoff, 1999)

  Support reinforced by the support of the rule !X -> !Y. See details: Casual Support

  Range: [-1, 1]

"counterexample", example and counter-example rate

  Rate of the examples minus the rate of counter examples (i.e., X -> !Y). See details: Example and Counter-example Rate

  Range: [0, 1]

"doc", difference of confidence (Hofmann and Wilhelm, 2001)

  Defined as the difference in confidence of the rule and the rule !X -> Y See details: Difference of Confidence

  Range: [-1, 1]

"fishersExactTest", Fisher's exact test (Hahsler and Hornik, 2007)

  p-value of Fisher's exact test used in the analysis of contingency tables where sample sizes are small. By default complementary effects are mined, substitutes can be found by using the parameter `complements = FALSE`. See details: Fisher's Exact Test

  Note that it is equal to hyper-confidence with `significance=TRUE`. Correction for multiple comparisons can be done using `p.adjust`.

  Range: [0, 1] (p-value scale)

"gini", Gini index (Tan et al., 2004)

  Measures quadratic entropy of a rule. See details: Gini index

  Range: [0, 1] (0 means the rule provides no information for the data set)

"hyperConfidence" (Hahsler and Hornik, 2007)

  Confidence level that the observed co-occurrence count of the LHS and RHS is too high given the expected count using the hypergeometric model. See details: Hyper-Confidence

  Hyper-confidence reports the confidence level by default and the significance level if `significance=TRUE` is used.

  By default complementary effects are mined, substitutes (too low co-occurrence counts) can be found by using the parameter `complements = FALSE`.

  Range: [0, 1]

"hyperLift" (Hahsler and Hornik, 2007)

  Adaptation of the lift measure which evaluates the deviation from independence using a quantile of the hypergeometric distribution defined by the counts of the LHS and RHS. HyperLift can be used to calculate confidence intervals for the lift measure. See details: Hyper-Lift

  The used quantile can be given as parameter `d` (default: `d=0.99`).

  Range: [0, Inf] (1 indicates independence)

"imbalance", imbalance ratio, IR (Wu, Chen and Han, 2010)

  IR measures the degree of imbalance between the two events that the lhs and the rhs are contained in a transaction. The ratio is close to 0 if the conditional probabilities are similar (i.e., very balanced) and close to 1 if they are very different. See also: Imbalance ratio

  Range: [0, 1] (0 indicates a balanced rule)

"implicationIndex", implication index (Gras, 1996)

  A variation of the Lerman similarity. See details: Implication Index

  Range: [0, 1] (0 means independence)

"importance" (MS Analysis Services)

  Log likelihood of the right-hand side of the rule, given the left-hand side of the rule using Laplace corrected confidence. See details: Importance

  Range: [-Inf, Inf]

"improvement" (Bayardo et al., 2000)

  The improvement of a rule is the minimum difference between its confidence and the confidence of any more general rule (i.e., a rule with the same consequent but one or more items removed in the LHS). Special case: We define improvement for a rules with an empty LHS as its confidence.

  See details: Improvement

  Range: [0, 1]

"jaccard", Jaccard coefficient (Tan and Kumar, 2000) sometimes also called Coherence (Wu et al., 2010)

  Null-invariant measure of dependence defined as the Jaccard similarity between the two sets of transactions that contain the items in X and Y, respectively. See details: Jaccard coefficient

  Range: [0, 1]

"jMeasure", J-measure, J (Smyth and Goodman, 1991)

  A scaled measures of cross entropy to measure the information content of a rule. See details: J-Measure

  Range: [0, 1] (0 indicates X does not provide information for Y)

"kappa" Cohen's Kappa (Tan and Kumar, 2000)

  Cohen's Kappa of the rule (seen as a classifier) given as the rules observed rule accuracy (i.e., confidence) corrected by the expected accuracy (of a random classifier). See details: Cohen's Kappa

  Range: [-1,1] (0 means the rule is not better than a random classifier)

"klosgen", Klosgen (Tan and Kumar, 2000)

  Defined as sqrt(supp(X & Y)) conf(X -> Y) - supp(Y) See details: Klosgen measure

  Range: [-1, 1] (0 for independence)

"kulczynski" (Wu, Chen and Han, 2010; Kulczynski, 1927)

  Calculate the null-invariant Kulczynski measure with a preference for skewed patterns. See details: Kulczynski measure

  Range: [0, 1]

"lambda", Goodman-Kruskal's lambda, predictive association (Tan and Kumar, 2000)

  Goodman and Kruskal's lambda to assess the association between the LHS and RHS of the rule. See details: Goodman-Kruskal's Lambda

  Range: [0, 1]

"laplace", Laplace corrected confidence/accuracy, L (Tan and Kumar 2000)

  Estimates confidence by increasing each count by 1. Parameter `k` can be used to specify the number of classes (default is 2). Prevents counts of 0 and L decreases with lower support. See details: Laplace corrected confidence/accuracy

  Range: [0, 1]

"leastContradiction", least contradiction (Aze and Kodratoff, 2004

  Probability of finding a matching transaction minus the probability of finding a contradicting transaction normalized by the probability of finding a transaction containing Y. See details: Least Contradiction

  Range: [-1, 1]

"lerman", Lerman similarity (Lerman, 1981)

  Defined as sqrt(N) (supp(X & Y) - supp(X)supp(Y))/ sqrt(supp(X)supp(Y)) See details: Lerman similarity

  Range: [0, 1]

"leverage", Piatetsky-Shapiro Measure, PS (Piatetsky-Shapiro 1991)

  PS measures the difference of X and Y appearing together in the data set and what would be expected if X and Y where statistically dependent. It can be interpreted as the gap to independence. See details: Leverage

  Range: [-1, 1] (0 indicates independence)

"lift", interest factor (Brin et al. 1997)

  Lift quantifies dependence between X and Y by comparing the probability that X and Y are contained in a transaction to the expected probability under independence (i.e., the product of the probabilities that X is contained in a transaction times the probability that Y is contained in a transaction). See details: Lift

  Range: [0, Inf] (1 means independence between LHS and RHS)

"maxConfidence" (Wu et al. 2010)

  Null-invariant symmetric measure defined as the larger of the confidence of the rule or the rule with X and Y exchanged. See details: MaxConfidence

  Range: [0, 1]

"mutualInformation", uncertainty, M (Tan et al., 2002)

  Measures the information gain for Y provided by X. See details: Mutual Information

  Range: [0, 1] (0 means that X does not provide information for Y)

"oddsRatio", odds ratio alpha (Tan et al., 2004)

  The odds of finding X in transactions which contain Y divided by the odds of finding X in transactions which do not contain Y. See details: Odds Ratio

  Range: [0, Inf] (1 indicates that Y is not associated to X)

"phi", correlation coefficient phi (Tan et al., 2004

  Correlation coefficient between the transactions containing X and Y represented as two binary vectors. Phi correlation is equivalent to Pearson's Product Moment Correlation Coefficient rho with 0-1 values. See details: Phi Correlation Coefficient

  Range: [-1, 1] (0 when X and Y are independent)

"ralambondrainy", Ralambondrainy Measure (Diatta et al., 2007)

  The measure is defined as the probability that a transaction contains X but not Y. A smaller value is better. See details: Ralambondrainy Measure

  Range: [0, 1]

"rhsSupport", Support of the rule consequent

  Range: [0, 1]

"RLD", relative linkage disequilibrium (Kenett and Salini, 2008)

  RLD is an association measure motivated by indices used in population genetics. It evaluates the deviation of the support of the whole rule from the support expected under independence given the supports of the LHS and the RHS. See details: Relative linkage disequilibrium

  The code was contributed by Silvia Salini.

  Range: [0, 1]

"rulePowerFactor", rule power factor (Ochin et al., 2016)

  Product of support and confidence. Can be seen as rule confidence weighted by support. See details: Rule Power Factor

  Range: [0, 1]

"sebag", Sebag-Schoenauer measure (Sebag and Schoenauer, 1988)

  Confidence of a rule divided by the confidence of the rule X -> !Y. See details: Sebag-Schoenauer measure

  Range: [0, 1]

"stdLift", Standardized Lift (McNicholas et al, 2008)

  Standardized lift uses the minimum and maximum lift can reach for each rule to standardize lift between 0 and 1. By default, the measure is corrected for minimum support and minimum confidence. Correction can be disabled by using the argument `correct = FALSE`.

  See details: Standardized Lift

  Range: [0, 1]

"support", supp (Agrawal et al., 1996)

  Support is an estimate of P(X & Y) and measures the generality of the rule. See details: Support

  Range: [0, 1]

"varyingLiaison", varying rates liaison (Bernard and Charron, 1996)

  Defined as the lift of a rule minus 1 so 0 represents independence. See details: Varying Rates Liaison

  Range: [-1, ∞] (0 for independence)

"yuleQ", Yule's Q (Tan and Kumar, 2000)

  Defined as (alpha-1)/(alpha+1) where alpha is the odds ratio. See details: Yule's Q

  Range: [-1, 1]

"yuleY", Yule's Y (Tan and Kumar, 2000)

  Defined as (sqrt(alpha)-1)/(sqrt(alpha)+1) where alpha is the odds ratio. See details: Yule's Y

  Range: [-1, 1]

### Value

If only one measure is used, the function returns a numeric vector containing the values of the interest measure for each association in the set of associations `x`.

If more than one measures are specified, the result is a data.frame containing the different measures for each association as columns.

`NA` is returned for rules/itemsets for which a certain measure is not defined.

### Author(s)

Michael Hahsler

### References

Hahsler, Michael (2015). A Probabilistic Comparison of Commonly Used Interest Measures for Association Rules, 2015, URL: https://michael.hahsler.net/research/association_rules/measures.html.

Agrawal, R., H Mannila, R Srikant, H Toivonen, AI Verkamo (1996). Fast Discovery of Association Rules. Advances in Knowledge Discovery and Data Mining 12(1):307–328.

Aze, J. and Y. Kodratoff (2004). Extraction de pepites de connaissances dans les donnees: Une nouvelle approche et une etude de sensibilite au bruit. In Mesures de Qualite pour la fouille de donnees. Revue des Nouvelles Technologies de l'Information, RNTI.

Jose L. Balcazar. Formal and computational properties of the confidence boost of association rules. ACM Transactions on Knowledge Discovery from Data, 7(4), December 2013.

Bayardo, R. , R. Agrawal, and D. Gunopulos (2000). Constraint-based rule mining in large, dense databases. Data Mining and Knowledge Discovery, 4(2/3):217–240.

Bernard, Jean-Marc and Charron, Camilo (1996). L'analyse implicative bayesienne, une methode pour l'etude des dependances orientees. II : modele logique sur un tableau de contingence Mathematiques et Sciences Humaines, Volume 135 (1996), p. 5–18.

Berzal, Fernando, Ignacio Blanco, Daniel Sanchez and Maria-Amparo Vila (2002). Measuring the accuracy and interest of association rules: A new framework. Intelligent Data Analysis 6, 221–235.

Bing, Liu, Wynne Hsu, and Yiming Ma (1999). Pruning and summarizing the discovered associations. In KDD '99: Proceedings of the fifth ACM SIGKDD international conference on Knowledge discovery and data mining, pages 125–134. ACM Press, 1999.

Brin, Sergey, Rajeev Motwani, Jeffrey D. Ullman, and Shalom Tsur (1997). Dynamic itemset counting and implication rules for market basket data. In SIGMOD 1997, Proceedings ACM SIGMOD International Conference on Management of Data, pages 255–264, Tucson, Arizona, USA.

Diatta, J., H. Ralambondrainy, and A. Totohasina (2007). Towards a unifying probabilistic implicative normalized quality measure for association rules. In Quality Measures in Data Mining, 237–250, 2007.

Gras R (1996). L'implication statistique. Nouvelle methode exploratoire de donnees. La Pensee Sauvage, Grenoble.

Hahsler, Michael and Kurt Hornik (2007). New probabilistic interest measures for association rules. Intelligent Data Analysis, 11(5):437–455.

Hofmann, Heike and Adalbert Wilhelm (2001). Visual comparison of association rules. Computational Statistics, 16(3):399–415.

Kenett, Ron and Silvia Salini (2008). Relative Linkage Disequilibrium: A New measure for association rules. In 8th Industrial Conference on Data Mining ICDM 2008, July 16–18, 2008, Leipzig/Germany.

Kodratoff, Y. (1999). Comparing Machine Learning and Knowledge Discovery in Databases: An Application to Knowledge Discovery in Texts. Lecture Notes on AI (LNAI) - Tutorial series.

Kulczynski, S. (1927). Die Pflanzenassoziationen der Pieninen. Bulletin International de l'Academie Polonaise des Sciences et des Lettres, Classe des Sciences Mathematiques et Naturelles B, 57–203.

Lerman, I.C. (1981). Classification et analyse ordinale des donnees. Paris.

McNicholas, P.D., T.B. Murphy, M. O'Regan (2008). Standardising the lift of an association rule, Computational Statistics & Data Analysis, 52(10):4712–4721, ISSN 0167-9473, doi: 10.1016/j.csda.2008.03.013.

Ochin, Suresh Kumar, and Nisheeth Joshi (2016). Rule Power Factor: A New Interest Measure in Associative Classification. 6th International Conference On Advances In Computing and Communications, ICACC 2016, 6-8 September 2016, Cochin, India.

Omiecinski, Edward R. (2003). Alternative interest measures for mining associations in databases. IEEE Transactions on Knowledge and Data Engineering, 15(1):57–69, Jan/Feb 2003.

Piatetsky-Shapiro, G. (1991). Discovery, analysis, and presentation of strong rules. In: Knowledge Discovery in Databases, pages 229–248.

Sebag, M. and M. Schoenauer (1988). Generation of rules with certainty and confidence factors from incomplete and incoherent learning bases. In Proceedings of the European Knowledge Acquisition Workshop (EKAW'88), Gesellschaft fuer Mathematik und Datenverarbeitung mbH, 28.1–28.20.

Smyth, Padhraic and Rodney M. Goodman (1991). Rule Induction Using Information Theory. Knowledge Discovery in Databases, 159–176.

Tan, Pang-Ning and Vipin Kumar (2000). Interestingness Measures for Association Patterns: A Perspective. TR 00-036, Department of Computer Science and Engineering University of Minnesota.

Tan, Pang-Ning, Vipin Kumar, and Jaideep Srivastava (2002). Selecting the right interestingness measure for association patterns. In Proceedings of the eighth ACM SIGKDD international conference on Knowledge discovery and data mining (KDD '02), ACM, 32–41.

Tan, Pang-Ning, Vipin Kumar, and Jaideep Srivastava (2004). Selecting the right objective measure for association analysis. Information Systems, 29(4):293–313.

Wu, T., Y. Chen, and J. Han (2010). Re-examination of interestingness measures in pattern mining: A unified framework. Data Mining and Knowledge Discovery, 21(3):371-397, 2010.

Xiong, Hui, Pang-Ning Tan, and Vipin Kumar (2003). Mining strong affinity association patterns in data sets with skewed support distribution. In Bart Goethals and Mohammed J. Zaki, editors, Proceedings of the IEEE International Conference on Data Mining, November 19–22, 2003, Melbourne, Florida, pages 387–394.

### See Also

`itemsets-class`, `rules-class`

### Examples

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

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

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

    ## calculate several measures
    m <- interestMeasure(rules, c("confidence", "oddsRatio", "leverage"),
    	transactions = Income)
    inspect(head(rules))
    head(m)

    ## calculate all available measures for the first 5 rules and show them as a
    ## table with the measures as rows
    t(interestMeasure(head(rules, 5), transactions = Income))

    ## calculate measures on a different set of transactions (I use a sample here)
    ## Note: reuse = TRUE (default) would just return the stored support on the
    ##	data set used for mining
    newTrans <- sample(Income, 100)
    m2 <- interestMeasure(rules, "support", transactions = newTrans, reuse = FALSE)
    head(m2)

    ## calculate all available measures for the 5 frequent itemsets with highest support
    its <- apriori(Income, parameter = list(target = "frequent itemsets"))
    its <- head(its, 5, by = "support")
    inspect(its)

    interestMeasure(its, transactions = Income)

[Package arules version 1.6-7 Index]