File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed
Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change 88WIKI: https://en.wikipedia.org/wiki/Apriori_algorithm
99"""
1010
11- from itertools import combinations
1211from collections import defaultdict
13-
12+ from itertools import combinations
1413
1514def load_data () -> list [list [str ]]:
1615 """
@@ -70,8 +69,7 @@ def find_frequent_itemsets(self):
7069 for i in range (len (keys )):
7170 for j in range (i + 1 , len (keys )):
7271 union = keys [i ] | keys [j ]
73- if len (union ) == k :
74- if all (frozenset (sub ) in current_itemsets for sub in combinations (union , k - 1 )):
72+ if len (union ) == k and all (frozenset (sub ) in current_itemsets for sub in combinations (union , k - 1 )):
7573 candidates .add (union )
7674
7775 freq_candidates = {c : self ._get_support (c ) for c in candidates if self ._get_support (c ) >= self .min_support }
You can’t perform that action at this time.
0 commit comments