wpi.associations.arminer
Class AssociationRule

java.lang.Object
  extended bywpi.associations.arminer.AssociationRule
All Implemented Interfaces:
java.io.Serializable

public class AssociationRule
extends java.lang.Object
implements java.io.Serializable

AssociationRule.java

An association rule has two parts: the antecedent of the rule and the consequent of the rule, both of which are sets of items. Associated with these are a support and a confidence. The support tells how many rows of a database support this rule, the confidence tells what percentage of the rows that contain the antecedent also contain the consequent.

See Also:
Serialized Form

Field Summary
private  int[] antecedent
          The antecedent.
static int ANTECEDENT_SIZE
           
private  float confidence
          The confidence of the association rule.
static int CONFIDENCE
           
private  int[] consequent
          The consequent.
static int CONSEQUENT_SIZE
           
private  float support
          The support of the association rule.
static int SUPPORT
           
 
Constructor Summary
AssociationRule(ARMinerItemset antecedent, ARMinerItemset consequent, float support, float confidence)
          Creates a new association rule.
 
Method Summary
 int antecedentSize()
          Return size of antecedent.
 int compareTo(AssociationRule ar, int criteria)
          Compare two AssociationRule objects on one of several criteria.
 int consequentSize()
          Return size of consequent.
 boolean equals(java.lang.Object obj)
          Compare two AssociationRule objects on one of several criteria.
 int getAntecedentItem(int i)
          Return i-th item in antecedent.
 float getConfidence()
          Return confidence of association rule.
 int getConsequentItem(int i)
          Return i-th item in consequent.
 float getSupport()
          Return support of association rule.
static void main(java.lang.String[] args)
          for testing purposes only !!!
 java.lang.String toString()
          Return a String representation of the AssociationRule.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANTECEDENT_SIZE

public static final int ANTECEDENT_SIZE
See Also:
Constant Field Values

CONSEQUENT_SIZE

public static final int CONSEQUENT_SIZE
See Also:
Constant Field Values

SUPPORT

public static final int SUPPORT
See Also:
Constant Field Values

CONFIDENCE

public static final int CONFIDENCE
See Also:
Constant Field Values

antecedent

private int[] antecedent
The antecedent.


consequent

private int[] consequent
The consequent.


support

private float support
The support of the association rule.


confidence

private float confidence
The confidence of the association rule.

Constructor Detail

AssociationRule

public AssociationRule(ARMinerItemset antecedent,
                       ARMinerItemset consequent,
                       float support,
                       float confidence)
Creates a new association rule.

Parameters:
antecedent - the antecedent of the association rule
consequent - the consequent of the association rule
support - the support of the association rule
confidence - the confidence of the association rule
Throws:
java.lang.IllegalArgumentException - antecedent or consequent are null or support or confidence are not between 0 and 1
Method Detail

antecedentSize

public int antecedentSize()
Return size of antecedent.

Returns:
size of antecedent

consequentSize

public int consequentSize()
Return size of consequent.

Returns:
size of consequent

getSupport

public float getSupport()
Return support of association rule.


getConfidence

public float getConfidence()
Return confidence of association rule.


getAntecedentItem

public int getAntecedentItem(int i)
Return i-th item in antecedent.

Parameters:
i - the index of the item to get
Returns:
the i-th item in antecedent
Throws:
java.lang.IndexOutOfBoundsException - i is an invalid index

getConsequentItem

public int getConsequentItem(int i)
Return i-th item in consequent.

Parameters:
i - the index of the item to get
Returns:
the i-th item in consequent
Throws:
java.lang.IndexOutOfBoundsException - i is an invalid index

compareTo

public int compareTo(AssociationRule ar,
                     int criteria)
Compare two AssociationRule objects on one of several criteria.

Parameters:
ar - the AssociationRule object with which we want to compare this object
criteria - the criteria on which we want to compare, can be one of ANTECEDENT_SIZE, CONSEQUENT_SIZE, SUPPORT or CONFIDENCE.
Returns:
a negative value if this object is smaller than ar, 0 if they are equal, and a positive value if this object is greater.
Throws:
java.lang.IllegalArgumentException - ar is null or criteria is invalid

equals

public boolean equals(java.lang.Object obj)
Compare two AssociationRule objects on one of several criteria.

Returns:
true if the objects are equal in terms of antecedent and consequent items; false otherwise.

toString

public java.lang.String toString()
Return a String representation of the AssociationRule.

Returns:
String representation of AssociationRule

main

public static void main(java.lang.String[] args)
for testing purposes only !!!