Class ItemSet

  • All Implemented Interfaces:
    Serializable

    public class ItemSet
    extends Object
    implements Serializable
    A representation of a set of items with their support (frequency) within a data set. Items are represented by int values. It is assumed that each item has a distinct integer identifier.

    The necessary methods are implemented allowing instances of this class to be used within the standard utility library (i.e. HashMap ...).

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ItemSet​(int itemID)
      Construct an item set with a single item.
      ItemSet​(int[] itemIDs)
      Construct an item set from the given items.
      ItemSet​(int[] itemIDs, int length)
      Create an item set from the list of items specifying how many from the list to use.
      ItemSet​(int[] itemsLHS, int[] itemsRHS)
      Combine the two sets of items into one set.
      ItemSet​(int[] itemIDs, long support, double supportPct)
      Construct an item set from the given items.
      ItemSet​(int itemID, int[] itemIDs)
      Combine the given singular item and a list of items into a single item set.
    • Constructor Detail

      • ItemSet

        public ItemSet​(int itemID)
        Construct an item set with a single item.
        Parameters:
        itemID - item identifier
      • ItemSet

        public ItemSet​(int[] itemIDs)
        Construct an item set from the given items. Assume ownership of the array.
        Parameters:
        itemIDs - items within the item set
      • ItemSet

        public ItemSet​(int[] itemIDs,
                       long support,
                       double supportPct)
        Construct an item set from the given items. Assume ownership of the array. Use the given support values for initial values.
        Parameters:
        itemIDs - items within the item set
        support - the initial support value
        supportPct - the initial support percentage value
      • ItemSet

        public ItemSet​(int itemID,
                       int[] itemIDs)
        Combine the given singular item and a list of items into a single item set.
        Parameters:
        itemID - the singular item
        itemIDs - a list of items
      • ItemSet

        public ItemSet​(int[] itemsLHS,
                       int[] itemsRHS)
        Combine the two sets of items into one set.
        Parameters:
        itemsLHS - a list of item identifiers
        itemsRHS - a list of item identifiers
      • ItemSet

        public ItemSet​(int[] itemIDs,
                       int length)
        Create an item set from the list of items specifying how many from the list to use.
        Parameters:
        itemIDs - the item identifiers
        length - the number of items to include
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • represents

        public boolean represents​(int[] items)
        Returns whether the given list of items matches the list of items within this item set.
        Parameters:
        items - item identifiers
        Returns:
        true if all items match, false otherwise
      • size

        public int size()
        Return the size of this item set.
        Returns:
        the size of the item set
      • getItemIDs

        public int[] getItemIDs()
        Get the item identifiers contained in this item list.
        Returns:
        list of item identifiers
      • calculateSupportPct

        public void calculateSupportPct​(long transactionTotal)
        Given the number of transactions in a DB compute the support percent for this item set.
        Parameters:
        transactionTotal - total number of transactions
      • getSupportPct

        public double getSupportPct()
        Get the support percentage value.
        Returns:
        support percentage (support / transaction count)
      • incrementSupport

        public void incrementSupport()
        Increment the support value.
      • getSupport

        public long getSupport()
        Get the current support value.
        Returns:
        support value
      • setSupport

        public void setSupport​(long support)
        Set the support value.
        Parameters:
        support - support value to set
      • newSetSizeComparator

        public static Comparator<ItemSet> newSetSizeComparator()
        Create a new Comparator that compares item sets and allows sorting by item set size and support.
        Returns:
        a new Comparator instance