Package weka.associations

# Class LabeledItemSet

java.lang.Object
weka.associations.ItemSet
weka.associations.LabeledItemSet

All Implemented Interfaces:
  `Serializable`, `RevisionHandler`

public class LabeledItemSet extends ItemSet implements 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:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LabeledItemSet(int totalTrans, int classLabel)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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
  `static Instances`
  `divide(Instances instances, boolean invert)`
  Splits the class attribute away.
  `final boolean`
  `equalCondset(Object itemSet)`
  Compares two item sets
  `final boolean`
  `equals(Object itemSet)`
  Tests if two item sets are equal.
  `final ArrayList<Object>[]`
  `generateRules(double minConfidence, boolean noPrune)`
  Generates rules out of item sets
  `static Hashtable<ItemSet,Integer>`
  `getHashtable(ArrayList<Object> itemSets, int initialSize)`
  Return a hashtable filled with the given item sets.
  `String`
  `getRevision()`
  Returns the revision string.
  `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.
  `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.
  `static ArrayList<Object>`
  `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 set
  `static void`
  `upDateCountersTreatZeroAsMissing(ArrayList<LabeledItemSet> itemSets, Instances instancesNoClass, Instances instancesClass)`
  Updates counter of a specific item set
  `final 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`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LabeledItemSet

    public LabeledItemSet(int totalTrans, int classLabel)
    Constructor
    Parameters:
      `totalTrans` - the total number of transactions
      `classLabel` - 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 support
      `itemSets` - the set of item sets to be pruned
      `minSupport` - the minimum number of transactions to be covered
    Returns:
      the reduced set of item sets

  - ### equals

    public final boolean equals(Object itemSet)
    Tests if two item sets are equal.
    Overrides:
      `equals` in class `ItemSet`
    Parameters:
      `itemSet` - another item set
    Returns:
      true if this item set contains the same items as the given one

  - ### equalCondset

    public final boolean equalCondset(Object itemSet)
    Compares two item sets
    Parameters:
      `itemSet` - an item set
    Returns:
      true if the the item sets are equal, false otherwise

  - ### getHashtable

    public static Hashtable<ItemSet,Integer> getHashtable(ArrayList<Object> itemSets, int initialSize)
    Return a hashtable filled with the given item sets.
    Parameters:
      `itemSets` - the set of item sets to be used for filling the hash table
      `initialSize` - 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 transactions
      `itemSets` - the set of (k-1)-item sets
      `size` - the value of (k-1)
    Returns:
      the generated (k)-item sets

  - ### divide

    public static Instances divide(Instances instances, boolean invert) throws Exception
    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 instances
      `invert` - 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 attribute
      `classes` - 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 pruned
      `kMinusOne` - 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.
    Overrides:
      `support` in class `ItemSet`
    Returns:
      the support

  - ### upDateCounter

    public final void upDateCounter(Instance instanceNoClass, Instance instanceClass)
    Updates counter of item set with respect to given transaction.
    Parameters:
      `instanceNoClass` - instances without the class attribute
      `instanceClass` - the values of the class attribute sorted according to instances

  - ### upDateCounterTreatZeroAsMissing

    public final void upDateCounterTreatZeroAsMissing(Instance instanceNoClass, Instance instanceClass)
    Updates counter of item set with respect to given transaction.
    Parameters:
      `instanceNoClass` - instances without the class attribute
      `instanceClass` - 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 sets
      `instancesNoClass` - instances without the class attribute
      `instancesClass` - 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 sets
      `instancesNoClass` - instances without the class attribute
      `instancesClass` - the values of the class attribute sorted according to instances

  - ### generateRules

    public final ArrayList<Object>[] generateRules(double minConfidence, boolean noPrune)
    Generates rules out of item sets
    Parameters:
      `minConfidence` - the minimum confidence
      `noPrune` - flag indicating whether the rules are pruned accoridng to the minimum confidence value
    Returns:
      a set of rules

  - ### getRevision

    public String getRevision()
    Returns the revision string.
    Specified by:
      `getRevision` in interface `RevisionHandler`
    Overrides:
      `getRevision` in class `ItemSet`
    Returns:
      the revision