Package weka.associations
Class LabeledItemSet
java.lang.Object
weka.associations.ItemSet
weka.associations.LabeledItemSet
- All Implemented Interfaces:
Serializable
,RevisionHandler
Class for storing a set of items together with a class label. 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. The class provides the methods used for item sets in class association
rule mining. Because every item set knows its class label the training set
can be splitted up virtually.
- Version:
- $Revision: 10203 $
- Author:
- Stefan Mutter (mutter@cs.waikato.ac.nz)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondeleteItemSets
(ArrayList<Object> itemSets, int minSupport, int maxSupport) Deletes all item sets that don't have minimum support and have more than maximum supportstatic Instances
Splits the class attribute away.final boolean
equalCondset
(Object itemSet) Compares two item setsfinal boolean
Tests if two item sets are equal.generateRules
(double minConfidence, boolean noPrune) Generates rules out of item setsgetHashtable
(ArrayList<Object> itemSets, int initialSize) Return a hashtable filled with the given item sets.Returns the revision string.mergeAllItemSets
(ArrayList<Object> 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.Prunes a set of (k)-item sets using the given (k-1)-item sets.singletons
(Instances instancesNoClass, Instances classes) Converts the header info of the given set of instances into a set of item sets (singletons).final int
support()
Outputs the support for an item set.final void
upDateCounter
(Instance instanceNoClass, Instance instanceClass) Updates counter of item set with respect to given transaction.static void
upDateCounters
(ArrayList<Object> itemSets, Instances instancesNoClass, Instances instancesClass) Updates counter of a specific item setstatic void
upDateCountersTreatZeroAsMissing
(ArrayList<LabeledItemSet> itemSets, Instances instancesNoClass, Instances instancesClass) Updates counter of a specific item setfinal void
upDateCounterTreatZeroAsMissing
(Instance instanceNoClass, Instance instanceClass) Updates counter of item set with respect to given transaction.Methods inherited from class weka.associations.ItemSet
containedBy, containedByTreatZeroAsMissing, counter, getItems, getTotalTransactions, hashCode, itemAt, items, pruneRules, setCounter, setItem, setItemAt, singletons, toString, toString, upDateCounter, upDateCounters, upDateCountersTreatZeroAsMissing, updateCounterTreatZeroAsMissing
-
Constructor Details
-
LabeledItemSet
public LabeledItemSet(int totalTrans, int classLabel) Constructor- Parameters:
totalTrans
- the total number of transactionsclassLabel
- the class lebel
-
-
Method Details
-
deleteItemSets
public static ArrayList<Object> deleteItemSets(ArrayList<Object> itemSets, int minSupport, int maxSupport) Deletes all item sets that don't have minimum support and have more than maximum support- Parameters:
maxSupport
- the maximum supportitemSets
- the set of item sets to be prunedminSupport
- the minimum number of transactions to be covered- Returns:
- the reduced set of item sets
-
equals
Tests if two item sets are equal. -
equalCondset
Compares two item sets- Parameters:
itemSet
- an item set- Returns:
- true if the the item sets are equal, false otherwise
-
getHashtable
Return a hashtable filled with the given item sets.- Parameters:
itemSets
- the set of item sets to be used for filling the hash tableinitialSize
- the initial size of the hashtable- Returns:
- the generated hashtable
-
mergeAllItemSets
public static ArrayList<Object> mergeAllItemSets(ArrayList<Object> 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.- Parameters:
totalTrans
- the total number of transactionsitemSets
- the set of (k-1)-item setssize
- the value of (k-1)- Returns:
- the generated (k)-item sets
-
divide
Splits the class attribute away. Depending on the invert flag, the instances without class attribute or only the class attribute of all instances is returned- Parameters:
instances
- the instancesinvert
- flag; if true only the class attribute remains, otherweise the class attribute is the only attribute that is deleted.- Returns:
- Instances without the class attribute or instances with only the class attribute
- Throws:
Exception
- exception if instances cannot be splitted
-
singletons
public static ArrayList<Object> singletons(Instances instancesNoClass, Instances classes) throws Exception Converts the header info of the given set of instances into a set of item sets (singletons). The ordering of values in the header file determines the lexicographic order. Each item set knows its class label.- Parameters:
instancesNoClass
- instances without the class attributeclasses
- the values of the class attribute sorted according to instances- Returns:
- a set of item sets, each containing a single item
- Throws:
Exception
- if singletons can't be generated successfully
-
pruneItemSets
public static ArrayList<Object> pruneItemSets(ArrayList<Object> toPrune, Hashtable<ItemSet, Integer> kMinusOne) Prunes a set of (k)-item sets using the given (k-1)-item sets.- Parameters:
toPrune
- the set of (k)-item sets to be prunedkMinusOne
- the (k-1)-item sets to be used for pruning- Returns:
- the pruned set of item sets
-
support
public final int support()Outputs the support for an item set. -
upDateCounter
Updates counter of item set with respect to given transaction.- Parameters:
instanceNoClass
- instances without the class attributeinstanceClass
- the values of the class attribute sorted according to instances
-
upDateCounterTreatZeroAsMissing
Updates counter of item set with respect to given transaction.- Parameters:
instanceNoClass
- instances without the class attributeinstanceClass
- the values of the class attribute sorted according to instances
-
upDateCounters
public static void upDateCounters(ArrayList<Object> itemSets, Instances instancesNoClass, Instances instancesClass) Updates counter of a specific item set- Parameters:
itemSets
- an item setsinstancesNoClass
- instances without the class attributeinstancesClass
- the values of the class attribute sorted according to instances
-
upDateCountersTreatZeroAsMissing
public static void upDateCountersTreatZeroAsMissing(ArrayList<LabeledItemSet> itemSets, Instances instancesNoClass, Instances instancesClass) Updates counter of a specific item set- Parameters:
itemSets
- an item setsinstancesNoClass
- instances without the class attributeinstancesClass
- the values of the class attribute sorted according to instances
-
generateRules
Generates rules out of item sets- Parameters:
minConfidence
- the minimum confidencenoPrune
- flag indicating whether the rules are pruned accoridng to the minimum confidence value- Returns:
- a set of rules
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classItemSet
- Returns:
- the revision
-