ItemSet Pattern#
- class paspailleur.bip.ItemSetPattern(value: PatternValueType)#
A class representing a set of items as a pattern.
This class allows for the creation and manipulation of patterns that consist of a set of items. It supports operations such as union, intersection, and difference.
References#
Agrawal, R., & Srikant, R. (1994). Fast algorithms for mining association rules in large databases.
Attributes#
- PatternValueType:
The type of the pattern’s value, which is a frozenset.
Properties#
- value
Return the value of the item set pattern
- atomic_patterns
Return the set of all less precise patterns that cannot be obtained by intersection of other patterns.
- min_pattern
Return the minimal possible pattern for the item set pattern.
- PatternValueType#
alias of
frozenset
- property value: frozenset#
Return the value of the item set pattern.
- Returns:
value – The value of the itemset pattern, so the set of items itself.
- Return type:
PatternValueType
Examples
>>> p = ItemSetPattern({1, 2, 3}) >>> p.value frozenset({1, 2, 3})
- classmethod parse_string_description(value: str) frozenset #
Parse a string description into an item set pattern value.
- Parameters:
value (str) – The string description of the item set pattern.
- Returns:
parsed – The parsed item set pattern value.
- Return type:
PatternValueType
- Raises:
ValueError – If the value cannot be parsed into an ItemSetPattern object.
Examples
>>> ItemSetPattern.parse_string_description('{1, 2, 3}') frozenset({1, 2, 3})
- classmethod preprocess_value(value: Collection) frozenset #
Preprocess the value before storing it in the item set pattern.
- Parameters:
value (Collection) – The value to preprocess.
- Returns:
value – The preprocessed value as a frozenset.
- Return type:
frozenset
Examples
>>> ItemSetPattern.preprocess_value([1, 2, 2]) frozenset({1, 2})
- atomise(atoms_configuration: Literal['min', 'max'] = 'min') set[Self] #
Split the pattern into atomic patterns, i.e. ItemSets containing just one item.
- Parameters:
atoms_configuration (Literal['min', 'max']) – Specifically for ItemSetPattern, the value of atoms_configuration parameter does not affect the output of the function.
- Returns:
atomic_patterns – The set of atomic patterns, i.e. the set of unsplittable patterns whose join equals to the pattern.
- Return type:
set[Self]
Notes
Speaking in terms of Ordered Set Theory: We say that every pattern can be represented as the join of a subset of atomic patterns, that are join-irreducible elements of the lattice of all patterns.
Considering the set of atomic patterns as a partially ordered set (where the order follows the order on patterns), every pattern can be represented by an _antichain_ of atomic patterns (when atoms_configuration = ‘min’), and by an order ideal of atomic patterns (when atoms_configuration = ‘max’).
- property atomic_patterns: set[Self]#
Return the set of all less precise patterns that cannot be obtained by intersection of other patterns.
For an ItemSetPattern an atomic pattern is a pattern containing one itme.
- Returns:
atoms – A set of atomic patterns, each containing a single item from the item set pattern.
- Return type:
set[Self]
Examples
>>> p = ItemSetPattern({1, 2}) >>> p.atomic_patterns {ItemSetPattern({1}), ItemSetPattern({2})}
- classmethod get_min_pattern() Self #
Return the minimal possible pattern, i.e. empty ItemSetPattern
- Returns:
The minimal item set pattern, which is an empty frozenset. None if undefined
- Return type:
Self
Examples
>>> ItemSetPattern.get_min_pattern() ItemSetPattern(frozenset())