Record Class AssociationRule

java.lang.Object
java.lang.Record
smile.association.AssociationRule
Record Components:
antecedent - the antecedent itemset (LHS) of the association rule.
consequent - the consequent itemset (RHS) of the association rule.
support - the proportion of instances in the dataset that contain an itemset.
confidence - the percentage of instances that contain the consequent and antecedent together over the number of instances that only contain the antecedent.
lift - how many times more often antecedent and consequent occur together than expected if they were statistically independent.
leverage - the difference between the probability of the rule and the expected probability if the items were statistically independent.

public record AssociationRule(int[] antecedent, int[] consequent, double support, double confidence, double lift, double leverage) extends Record
Association rule object. Let I = {i1, i2,..., in} be a set of n binary attributes called items. Let D = {t1, t2,..., tm} be a set of transactions called the database. Each transaction in D has a unique transaction ID and contains a subset of the items in I. An association rule is defined as an implication of the form X ⇒ Y where X, Y ⊆ I and X ∩ Y = Ø. The item sets X and Y are called antecedent (left-hand-side or LHS) and consequent (right-hand-side or RHS) of the rule, respectively.

The support supp(X) of an item set X is defined as the proportion of transactions in the database which contain the item set. Note that the support of an association rule X ⇒ Y is supp(X ∪ Y).

The confidence of a rule is defined as conf(X ⇒ Y) = supp(X ∪ Y) / supp(X). Confidence can be interpreted as an estimate of the probability P(Y | X), the probability of finding the RHS of the rule in transactions under the condition that these transactions also contain the LHS.

Lift is a measure of the performance of a targeting model (association rule) at predicting or classifying cases as having an enhanced response (with respect to the population as a whole), measured against a random choice targeting model. A targeting model is doing a good job if the response within the target is much better than the average for the population as a whole. Lift is simply the ratio of these values: target response divided by average response. For an association rule X ⇒ Y, if the lift is equal to 1, it means that X and Y are independent. If the lift is higher than 1, it means that X and Y are positively correlated. If the lift is lower than 1, it means that X and Y are negatively correlated.

  • Constructor Summary

    Constructors
    Constructor
    Description
    AssociationRule(int[] antecedent, int[] consequent, double support, double confidence, double lift, double leverage)
    Creates an instance of a AssociationRule record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    Returns the value of the antecedent record component.
    double
    Returns the value of the confidence record component.
    int[]
    Returns the value of the consequent record component.
    boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    double
    Returns the value of the leverage record component.
    double
    Returns the value of the lift record component.
    double
    Returns the value of the support record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AssociationRule

      public AssociationRule(int[] antecedent, int[] consequent, double support, double confidence, double lift, double leverage)
      Creates an instance of a AssociationRule record class.
      Parameters:
      antecedent - the value for the antecedent record component
      consequent - the value for the consequent record component
      support - the value for the support record component
      confidence - the value for the confidence record component
      lift - the value for the lift record component
      leverage - the value for the leverage record component
  • Method Details

    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • antecedent

      public int[] antecedent()
      Returns the value of the antecedent record component.
      Returns:
      the value of the antecedent record component
    • consequent

      public int[] consequent()
      Returns the value of the consequent record component.
      Returns:
      the value of the consequent record component
    • support

      public double support()
      Returns the value of the support record component.
      Returns:
      the value of the support record component
    • confidence

      public double confidence()
      Returns the value of the confidence record component.
      Returns:
      the value of the confidence record component
    • lift

      public double lift()
      Returns the value of the lift record component.
      Returns:
      the value of the lift record component
    • leverage

      public double leverage()
      Returns the value of the leverage record component.
      Returns:
      the value of the leverage record component