|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.associations.ItemSet
Class for storing a set of items. Item sets are stored in a lexicographic order, which is determined by the header information of the set of instances used for generating the set of items. All methods in this class assume that item sets are stored in lexicographic order.
Field Summary | |
protected int |
m_counter
Counter for how many transactions contain this item set. |
protected int[] |
m_items
The items stored as an array of of ints. |
protected int |
m_totalTransactions
The total number of transactions |
Constructor Summary | |
ItemSet(int totalTrans)
Constructor |
Method Summary | |
static double |
confidenceForRule(ItemSet premise,
ItemSet consequence)
Outputs the confidence for a rule. |
boolean |
containedBy(Instance instance)
Checks if an instance contains an item set. |
double |
convictionForRule(ItemSet premise,
ItemSet consequence,
int premiseCount,
int consequenceCount)
Outputs the conviction for a rule. |
static FastVector |
deleteItemSets(FastVector itemSets,
int minSupport,
int maxSupport)
Deletes all item sets that don't have minimum support. |
boolean |
equals(java.lang.Object itemSet)
Tests if two item sets are equal. |
FastVector[] |
generateRules(double minConfidence,
FastVector hashtables,
int numItemsInSet)
Generates all rules for an item set. |
FastVector[] |
generateRulesBruteForce(double minMetric,
int metricType,
FastVector hashtables,
int numItemsInSet,
int numTransactions,
double significanceLevel)
Generates all significant rules for an item set. |
static java.util.Hashtable |
getHashtable(FastVector itemSets,
int initialSize)
Return a hashtable filled with the given item sets. |
int |
hashCode()
Produces a hash code for a item set. |
double |
leverageForRule(ItemSet premise,
ItemSet consequence,
int premiseCount,
int consequenceCount)
Outputs the leverage for a rule. |
double |
liftForRule(ItemSet premise,
ItemSet consequence,
int consequenceCount)
Outputs the lift for a rule. |
static FastVector |
mergeAllItemSets(FastVector itemSets,
int size,
int totalTrans)
Merges all item sets in the set of (k-1)-item sets to create the (k)-item sets and updates the counters. |
private FastVector[] |
moreComplexRules(FastVector[] rules,
int numItemsInSet,
int numItemsInConsequence,
double minConfidence,
FastVector hashtables)
Generates rules with more than one item in the consequence. |
static FastVector |
pruneItemSets(FastVector toPrune,
java.util.Hashtable kMinusOne)
Prunes a set of (k)-item sets using the given (k-1)-item sets. |
static void |
pruneRules(FastVector[] rules,
double minConfidence)
Prunes a set of rules. |
static FastVector |
singletons(Instances instances)
Converts the header info of the given set of instances into a set of item sets (singletons). |
ItemSet |
subtract(ItemSet toSubtract)
Subtracts an item set from another one. |
int |
support()
Outputs the support for an item set. |
java.lang.String |
toString(Instances instances)
Returns the contents of an item set as a string. |
void |
upDateCounter(Instance instance)
Updates counter of item set with respect to given transaction. |
static void |
upDateCounters(FastVector itemSets,
Instances instances)
Updates counters for a set of item sets and a set of instances. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int[] m_items
protected int m_counter
protected int m_totalTransactions
Constructor Detail |
public ItemSet(int totalTrans)
totalTrans
- the total number of transactions in the dataMethod Detail |
public static double confidenceForRule(ItemSet premise, ItemSet consequence)
premise
- the premise of the ruleconsequence
- the consequence of the rule
public double liftForRule(ItemSet premise, ItemSet consequence, int consequenceCount)
premise
- the premise of the ruleconsequence
- the consequence of the ruleconsequenceCount
- how many times the consequence occurs independent
of the premise
public double leverageForRule(ItemSet premise, ItemSet consequence, int premiseCount, int consequenceCount)
premise
- the premise of the ruleconsequence
- the consequence of the rulepremiseCount
- how many times the premise occurs independent
of the consequentconsequenceCount
- how many times the consequence occurs independent
of the premise
public double convictionForRule(ItemSet premise, ItemSet consequence, int premiseCount, int consequenceCount)
premise
- the premise of the ruleconsequence
- the consequence of the rulepremiseCount
- how many times the premise occurs independent
of the consequentconsequenceCount
- how many times the consequence occurs independent
of the premise
public final boolean containedBy(Instance instance)
instance
- the instance to be tested
public static FastVector deleteItemSets(FastVector itemSets, int minSupport, int maxSupport)
itemSets
- the set of item sets to be prunedminSupport
- the minimum number of transactions to be covered
public final boolean equals(java.lang.Object itemSet)
itemSet
- another item set
public final FastVector[] generateRules(double minConfidence, FastVector hashtables, int numItemsInSet)
minConfidence
- the minimum confidence the rules have to havehashtables
- containing all(!) previously generated
item setsnumItemsInSet
- the size of the item set for which the rules
are to be generated
public final FastVector[] generateRulesBruteForce(double minMetric, int metricType, FastVector hashtables, int numItemsInSet, int numTransactions, double significanceLevel) throws java.lang.Exception
minMetric
- the minimum metric (confidence, lift, leverage,
improvement) the rules have to havemetricType
- (confidence=0, lift, leverage, improvement)hashtables
- containing all(!) previously generated
item setsnumItemsInSet
- the size of the item set for which the rules
are to be generated
java.lang.Exception
- if something goes wrongpublic static java.util.Hashtable getHashtable(FastVector itemSets, int initialSize)
itemSets
- the set of item sets to be used for filling the hash tableinitialSize
- the initial size of the hashtable
public final int hashCode()
public static FastVector mergeAllItemSets(FastVector itemSets, int size, int totalTrans)
itemSets
- the set of (k-1)-item setssize
- the value of (k-1)
public static FastVector pruneItemSets(FastVector toPrune, java.util.Hashtable kMinusOne)
toPrune
- the set of (k)-item sets to be prunedkMinusOne
- the (k-1)-item sets to be used for pruning
public static void pruneRules(FastVector[] rules, double minConfidence)
rules
- a two-dimensional array of lists of item sets. The first list
of item sets contains the premises, the second one the consequences.minConfidence
- the minimum confidence the rules have to havepublic static FastVector singletons(Instances instances) throws java.lang.Exception
instances
- the set of instances whose header info is to be used
java.lang.Exception
- if singletons can't be generated successfullypublic final ItemSet subtract(ItemSet toSubtract)
toSubtract
- the item set to be subtracted from this one.
public final int support()
public final java.lang.String toString(Instances instances)
instances
- contains the relevant header information
public final void upDateCounter(Instance instance)
instance
- the instance to be used for ubdating the counterpublic static void upDateCounters(FastVector itemSets, Instances instances)
itemSets
- the set of item sets which are to be updatedinstances
- the instances to be used for updating the countersprivate final FastVector[] moreComplexRules(FastVector[] rules, int numItemsInSet, int numItemsInConsequence, double minConfidence, FastVector hashtables)
rules
- all the rules having (k-1)-item sets as consequencesnumItemsInSet
- the size of the item set for which the rules
are to be generatednumItemsInConsequence
- the value of (k-1)minConfidence
- the minimum confidence a rule has to havehashtables
- the hashtables containing all(!) previously generated
item sets
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |