|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwpi.associations.arminerSequence.AprioriRules
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 static int |
debug
Specifies debug info level 0: no debug info 1: input to methods 2: and output from methods 3: and all sorts of stuff |
private ARMinerItemset |
is_ignored
|
private ARMinerItemset |
is_in_antecedent
|
private ARMinerItemset |
is_in_consequent
|
private int |
maxAntecedent
|
private int |
maxConsequent
|
private int |
minAntecedent
|
private float |
minConfidence
|
private int |
minConsequent
|
private float |
minSupport
|
private java.util.Hashtable |
numberHash
Used to look up actual value of an item using its integer representation. |
private int |
numInstances
Number of instances in the data set. |
private java.util.Vector |
requiredAntecedents
Required antecedents for rule generated |
private java.util.Vector |
requiredConsequents
Required consequents for rule generated |
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)
This is the ap-genrules procedure that generates rules out of a frequent itemset. |
private void |
ap_genrules_constraint(ARMinerItemset is_frequent,
java.util.Vector consequents,
java.util.Vector antecedentAttributes,
java.util.Vector consequentAttributes)
This is the ap-genrules procedure that generates rules out of a frequent itemset. |
private void |
ap_genrules(ARMinerItemset is_frequent,
java.util.Vector consequents)
This is the ap-genrules procedure that generates rules out of a frequent itemset. |
private java.util.Vector |
apriori_gen(java.util.Vector itemsets)
This is the apriori_gen procedure that generates starting from a k-itemset collection a new collection of (k+1)-itemsets. |
private void |
buildRule(ARMinerItemset itemset,
int[] antIndexes,
int[] conIndexes)
Builds a rule based on the specified itemset indexes and adds it to the rules to be retuned. |
java.util.Vector |
findAssociations(DBCacheReader cacheReader,
float min_Support,
float min_Confidence)
Find association rules in a database, given the set of frequent itemsets. |
java.util.Vector |
findAssociations(DBCacheReader cacheReader,
float min_Support,
float min_Confidence,
ARMinerItemset inAntecedent,
ARMinerItemset inConsequent,
ARMinerItemset ignored,
int max_Antecedent,
int min_Consequent)
Find association rules in a database, given the set of frequent itemsets and a set of restrictions. |
java.util.Vector |
findAssociations(DBCacheReader cacheReader,
float min_Support,
float min_Confidence,
java.util.Vector antecedentAttributes,
java.util.Vector consequentAttributes,
int max_Antecedent,
int min_Consequent)
------------------- WEKA VERSION ------------------ Find association rules in a database, given the set of frequent itemsets and a set of restrictions. |
java.util.Vector |
findAssociations(DBCacheReader cacheReader,
float min_Support,
float min_Confidence,
java.util.Vector antecedentAttributes,
java.util.Vector consequentAttributes,
int min_Antecedent,
int max_Antecedent,
int min_Consequent,
int max_Consequent)
-------------- ANOTHER VERSION FOR WEKA ------------- Find association rules in a database, given the set of frequent itemsets and a set of restrictions. |
private void |
generateFromMaximal(ARMinerItemset itemset)
Generates all the possible rules from a maximal frequent itemset that meet all our criteria and adds them to the rules. |
private void |
generateFromMaximal(ARMinerItemset itemset,
int[] antIndexes,
int[] conIndexes,
int conLevel)
Generates all the possible rules from a maximal frequent itemset that meet all our criteria and adds them to the rules. |
private void |
generateFromMaximal(ARMinerItemset itemset,
int ant,
int con)
Generates all the possible rules from a maximal frequent itemset that meet all our criteria and adds them to the rules. |
private void |
generateFromMaximal(ARMinerItemset itemset,
int con,
int[] antIndexes,
int antLevel)
Generates all the possible rules from a maximal frequent itemset that meet all our criteria and adds them to the rules. |
java.util.Hashtable |
getNumberHash()
Returns the number hash used for looking up values in this itemset. |
int |
getNumInstances()
Returns the number of instances contained in the data set from which the frequent itemset were mined. |
private void |
initializeSupports(DBCacheReader cacheReader)
This method stores all frequent itemsets that have support greater than the minimum support in a SET for more efficient access times. |
private int |
removeDuplicateRules()
Removes duplicate rules from the rules list. |
private int |
removeDuplicateRules(int index)
Removes duplicate rules from the rules list. |
void |
setNumberHash(java.util.Hashtable h)
Sets the number hash to use for looking up values in this itemset |
void |
setNumInstances(int n)
Sets the number of instances contained in the data set from which the frequent itemset were mined. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private SET supports
private java.util.Vector rules
private float minSupport
private float minConfidence
private ARMinerItemset is_in_antecedent
private ARMinerItemset is_in_consequent
private ARMinerItemset is_ignored
private int minAntecedent
private int maxAntecedent
private int minConsequent
private int maxConsequent
private java.util.Vector requiredAntecedents
private java.util.Vector requiredConsequents
private int numInstances
private java.util.Hashtable numberHash
private static final int debug
Constructor Detail |
public AprioriRules()
Method Detail |
public void setNumberHash(java.util.Hashtable h)
h
- the number hashpublic java.util.Hashtable getNumberHash()
public void setNumInstances(int n)
n
- the number of instances or rowspublic int getNumInstances()
private void initializeSupports(DBCacheReader cacheReader)
public java.util.Vector findAssociations(DBCacheReader cacheReader, float min_Support, float min_Confidence)
findAssociations
in interface AssociationsFinder
cacheReader
- the object used to read from the cachemin_Support
- the minimum supportmin_Confidence
- the minimum confidence
private void ap_genrules(ARMinerItemset is_frequent, java.util.Vector consequents)
private java.util.Vector apriori_gen(java.util.Vector itemsets)
public java.util.Vector findAssociations(DBCacheReader cacheReader, float min_Support, float min_Confidence, ARMinerItemset inAntecedent, ARMinerItemset inConsequent, ARMinerItemset ignored, int max_Antecedent, int min_Consequent)
findAssociations
in interface AssociationsFinder
cacheReader
- the object used to read from the cachemin_Support
- the minimum supportmin_Confidence
- the minimum confidenceinAntecedent
- the items that must appear in the antecedent
of each rule, if null then this constraint is ignoredinConsequent
- the items that must appear in the consequent
of each rule, if null then this constraint is ignoredignored
- the items that should be ignored,
if null then this constraint is ignoredmax_Antecedent
- the maximum number of items that can appear
in the antecedent of each rule, if 0 then this constraint is ignoredmin_Consequent
- the minimum number of items that should appear
in the consequent of each rule, if 0 then this constraint is ignored
public java.util.Vector findAssociations(DBCacheReader cacheReader, float min_Support, float min_Confidence, java.util.Vector antecedentAttributes, java.util.Vector consequentAttributes, int max_Antecedent, int min_Consequent)
cacheReader
- the object used to read from the cachemin_Support
- the minimum supportmin_Confidence
- the minimum confidenceantecedentAttributes
- 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 nullconsequentAttributes
- 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 nullmax_Antecedent
- the maximum number of items that can appear in the antecedent of each
rule, if 0 then this constraint is ignoredmin_Consequent
- the minimum number of items that should appear in the consequent of
each rule, if 0 then this constraint is ignored
public java.util.Vector findAssociations(DBCacheReader cacheReader, float min_Support, float min_Confidence, java.util.Vector antecedentAttributes, java.util.Vector consequentAttributes, int min_Antecedent, int max_Antecedent, int min_Consequent, int max_Consequent)
cacheReader
- the object used to read from the cacheantecedentAttributes
- 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 nullconsequentAttributes
- 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
private void ap_genrules_constraint(ARMinerItemset is_frequent, java.util.Vector consequents, java.util.Vector antecedentAttributes, java.util.Vector consequentAttributes)
private void ap_genrules_constraint(ARMinerItemset is_frequent, java.util.Vector consequents)
private void generateFromMaximal(ARMinerItemset itemset)
itemset
- a maximal frequent itemset from which to build rulesprivate void generateFromMaximal(ARMinerItemset itemset, int ant, int con)
itemset
- a maximal frequent itemset from which to build rulesant
- the size to make the antecedentcon
- the size to make the consequentprivate void generateFromMaximal(ARMinerItemset itemset, int con, int[] antIndexes, int antLevel)
itemset
- a maximal frequent itemset from which to build rulescon
- the size to make the consequentantIndexes
- indexes into itemset to use for the antecedentantLevel
- the ant index to incrementprivate void generateFromMaximal(ARMinerItemset itemset, int[] antIndexes, int[] conIndexes, int conLevel)
itemset
- a maximal frequent itemset from which to build rulesantIndexes
- the antecedent indexesconIndexes
- the consequent indexesconLevel
- the consequent index to incrementprivate void buildRule(ARMinerItemset itemset, int[] antIndexes, int[] conIndexes)
itemset
- a maximal frequent itemset from which to build rulesantIndexes
- the antecedent indexesconIndexes
- the consequent indexesprivate int removeDuplicateRules()
private int removeDuplicateRules(int index)
index
- the index of the rule list where comparisons should
start
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |