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 8
8
WIKI: https://en.wikipedia.org/wiki/Apriori_algorithm
9
9
"""
10
10
11
- from itertools import combinations
12
11
from collections import defaultdict
13
-
12
+ from itertools import combinations
14
13
15
14
def load_data () -> list [list [str ]]:
16
15
"""
@@ -70,8 +69,7 @@ def find_frequent_itemsets(self):
70
69
for i in range (len (keys )):
71
70
for j in range (i + 1 , len (keys )):
72
71
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 )):
75
73
candidates .add (union )
76
74
77
75
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