@@ -73,7 +73,9 @@ def find_frequent_itemsets(self) -> List[Dict[frozenset, float]]:
7373
7474 total : int = len (self .transactions )
7575 current_itemsets : Dict [frozenset , float ] = {
76- k : v / total for k , v in item_counts .items () if v / total >= self .min_support
76+ k : v / total
77+ for k , v in item_counts .items ()
78+ if v / total >= self .min_support
7779 }
7880 if current_itemsets :
7981 self .itemsets .append (current_itemsets )
@@ -92,7 +94,9 @@ def find_frequent_itemsets(self) -> List[Dict[frozenset, float]]:
9294 candidates .add (union )
9395
9496 freq_candidates : Dict [frozenset , float ] = {
95- c : self ._get_support (c ) for c in candidates if self ._get_support (c ) >= self .min_support
97+ c : self ._get_support (c )
98+ for c in candidates
99+ if self ._get_support (c ) >= self .min_support
96100 }
97101 if not freq_candidates :
98102 break
@@ -103,7 +107,9 @@ def find_frequent_itemsets(self) -> List[Dict[frozenset, float]]:
103107
104108 return self .itemsets
105109
106- def generate_association_rules (self ) -> List [Tuple [frozenset , frozenset , float , float ]]:
110+ def generate_association_rules (
111+ self ,
112+ ) -> List [Tuple [frozenset , frozenset , float , float ]]:
107113 """Generate association rules with min confidence and lift."""
108114 for level in self .itemsets :
109115 for itemset in level :
@@ -121,7 +127,11 @@ def generate_association_rules(self) -> List[Tuple[frozenset, frozenset, float,
121127 conf ,
122128 lft ,
123129 )
124- if rule not in self .rules and conf >= self .min_confidence and lft >= self .min_lift :
130+ if (
131+ rule not in self .rules
132+ and conf >= self .min_confidence
133+ and lft >= self .min_lift
134+ ):
125135 self .rules .append (rule )
126136 return self .rules
127137
0 commit comments