- java.lang.Object
-
- com.pervasive.datarush.analytics.arm.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 byintvalues. 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalculateSupportPct(long transactionTotal)Given the number of transactions in a DB compute the support percent for this item set.booleanequals(Object o)int[]getItemIDs()Get the item identifiers contained in this item list.longgetSupport()Get the current support value.doublegetSupportPct()Get the support percentage value.inthashCode()voidincrementSupport()Increment the support value.static Comparator<ItemSet>newSetSizeComparator()Create a newComparatorthat compares item sets and allows sorting by item set size and support.booleanrepresents(int[] items)Returns whether the given list of items matches the list of items within this item set.voidsetSupport(long support)Set the support value.intsize()Return the size of this item set.StringtoString()
-
-
-
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 setsupport- the initial support valuesupportPct- 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 itemitemIDs- 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 identifiersitemsRHS- 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 identifierslength- the number of items to include
-
-
Method Detail
-
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 newComparatorthat compares item sets and allows sorting by item set size and support.- Returns:
- a new
Comparatorinstance
-
-