- 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 byint
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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
calculateSupportPct(long transactionTotal)
Given the number of transactions in a DB compute the support percent for this item set.boolean
equals(Object o)
int[]
getItemIDs()
Get the item identifiers contained in this item list.long
getSupport()
Get the current support value.double
getSupportPct()
Get the support percentage value.int
hashCode()
void
incrementSupport()
Increment the support value.static Comparator<ItemSet>
newSetSizeComparator()
Create a newComparator
that compares item sets and allows sorting by item set size and support.boolean
represents(int[] items)
Returns whether the given list of items matches the list of items within this item set.void
setSupport(long support)
Set the support value.int
size()
Return the size of this item set.String
toString()
-
-
-
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 newComparator
that compares item sets and allows sorting by item set size and support.- Returns:
- a new
Comparator
instance
-
-