wpi.associations.arminer
Class AprioriRules

java.lang.Object
  extended bywpi.associations.arminer.AprioriRules
All Implemented Interfaces:
AssociationsFinder

public class AprioriRules
extends java.lang.Object
implements AssociationsFinder

AprioriRules.java

This class implements the Apriori algorithm for finding association rules. (see "Fast Algorithms for Mining Association Rules" by Rakesh Agrawal and Ramakrishnan Srikant from IBM Almaden Research Center 1994)


Field Summary
private  ARMinerItemset is_ignored
           
private  ARMinerItemset is_in_antecedent
           
private  ARMinerItemset is_in_consequent
           
private  int max_antecedent
           
private  float min_confidence
           
private  int min_consequent
           
private  float min_support
           
private  java.util.Vector rules
           
private  SET supports
           
 
Constructor Summary
AprioriRules()
           
 
Method Summary
private  void ap_genrules_constraint(ARMinerItemset is_frequent, java.util.Vector consequents)
           
private  void ap_genrules_constraint(ARMinerItemset is_frequent, java.util.Vector consequents, java.util.Vector antecedentAttributes, java.util.Vector consequentAttributes)
           
private  void ap_genrules(ARMinerItemset is_frequent, java.util.Vector consequents)
           
private  java.util.Vector apriori_gen(java.util.Vector itemsets)
           
 java.util.Vector findAssociations(DBCacheReader cacheReader, float minSupport, float minConfidence)
          Find association rules in a database, given the set of frequent itemsets.
 java.util.Vector findAssociations(DBCacheReader cacheReader, float minSupport, float minConfidence, ARMinerItemset inAntecedent, ARMinerItemset inConsequent, ARMinerItemset ignored, int maxAntecedent, int minConsequent)
          Find association rules in a database, given the set of frequent itemsets and a set of restrictions.
 java.util.Vector findAssociations(DBCacheReader cacheReader, float minSupport, float minConfidence, java.util.Vector antecedentAttributes, java.util.Vector consequentAttributes, int maxAntecedent, int minConsequent)
          ------------------------WEKA VERSION!!!----------------------- Find association rules in a database, given the set of frequent itemsets and a set of restrictions.
private  void initializeSupports(DBCacheReader cacheReader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supports

private SET supports

rules

private java.util.Vector rules

min_support

private float min_support

min_confidence

private float min_confidence

is_in_antecedent

private ARMinerItemset is_in_antecedent

is_in_consequent

private ARMinerItemset is_in_consequent

is_ignored

private ARMinerItemset is_ignored

max_antecedent

private int max_antecedent

min_consequent

private int min_consequent
Constructor Detail

AprioriRules

public AprioriRules()
Method Detail

initializeSupports

private void initializeSupports(DBCacheReader cacheReader)

findAssociations

public java.util.Vector findAssociations(DBCacheReader cacheReader,
                                         float minSupport,
                                         float minConfidence)
Find association rules in a database, given the set of frequent itemsets.

Specified by:
findAssociations in interface AssociationsFinder
Parameters:
cacheReader - the object used to read from the cache
minSupport - the minimum support
minConfidence - the minimum confidence
Returns:
a Vector containing all association rules found

ap_genrules

private void ap_genrules(ARMinerItemset is_frequent,
                         java.util.Vector consequents)

apriori_gen

private java.util.Vector apriori_gen(java.util.Vector itemsets)

findAssociations

public java.util.Vector findAssociations(DBCacheReader cacheReader,
                                         float minSupport,
                                         float minConfidence,
                                         ARMinerItemset inAntecedent,
                                         ARMinerItemset inConsequent,
                                         ARMinerItemset ignored,
                                         int maxAntecedent,
                                         int minConsequent)
Find association rules in a database, given the set of frequent itemsets and a set of restrictions.

Specified by:
findAssociations in interface AssociationsFinder
Parameters:
cacheReader - the object used to read from the cache
minSupport - the minimum support
minConfidence - the minimum confidence
inAntecedent - the items that must appear in the antecedent of each rule, if null then this constraint is ignored
inConsequent - the items that must appear in the consequent of each rule, if null then this constraint is ignored
ignored - the items that should be ignored, if null then this constraint is ignored
maxAntecedent - the maximum number of items that can appear in the antecedent of each rule, if 0 then this constraint is ignored
minConsequent - the minimum number of items that should appear in the consequent of each rule, if 0 then this constraint is ignored
Returns:
a Vector containing all association rules found

findAssociations

public java.util.Vector findAssociations(DBCacheReader cacheReader,
                                         float minSupport,
                                         float minConfidence,
                                         java.util.Vector antecedentAttributes,
                                         java.util.Vector consequentAttributes,
                                         int maxAntecedent,
                                         int minConsequent)
------------------------WEKA VERSION!!!----------------------- Find association rules in a database, given the set of frequent itemsets and a set of restrictions.

Parameters:
cacheReader - the object used to read from the cache
minSupport - the minimum support
minConfidence - the minimum confidence
antecedentAttributes - a vector of ARMinerItemsets that each contains only items in a single attribute used to restrict which attributes must appear in the antecedent, ignored if null
consequentAttributes - a vector of ARMinerItemsets that each contains only items in a single attribute used to restrict which attributes must appear in the consequent, ignored if null
maxAntecedent - the maximum number of items that can appear in the antecedent of each rule, if 0 then this constraint is ignored
minConsequent - the minimum number of items that should appear in the consequent of each rule, if 0 then this constraint is ignored
Returns:
a Vector containing all association rules found

ap_genrules_constraint

private void ap_genrules_constraint(ARMinerItemset is_frequent,
                                    java.util.Vector consequents,
                                    java.util.Vector antecedentAttributes,
                                    java.util.Vector consequentAttributes)

ap_genrules_constraint

private void ap_genrules_constraint(ARMinerItemset is_frequent,
                                    java.util.Vector consequents)