We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 12e5cb3 commit f2b1f8aCopy full SHA for f2b1f8a
1 file changed
machine_learning/apriori_algorithm.py
@@ -8,9 +8,8 @@
8
WIKI: https://en.wikipedia.org/wiki/Apriori_algorithm
9
"""
10
11
-from itertools import combinations
12
from collections import defaultdict
13
-
+from itertools import combinations
14
15
def load_data() -> list[list[str]]:
16
@@ -70,8 +69,7 @@ def find_frequent_itemsets(self):
70
69
for i in range(len(keys)):
71
for j in range(i + 1, len(keys)):
72
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)):
+ if len(union) == k and all(frozenset(sub) in current_itemsets for sub in combinations(union, k - 1)):
75
candidates.add(union)
76
77
freq_candidates = {c: self._get_support(c) for c in candidates if self._get_support(c) >= self.min_support}
0 commit comments