Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reducing H_1 #44

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions efficient_apriori/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,12 @@ def count(itemset):

# For every itemset of this size
for itemset in itemsets[size].keys():
# Generate combinations to start off of. These 1-combinations will
# be merged to 2-combinations in the function `_ap_genrules`
H_1 = list(itertools.combinations(itemset, 1))

# Special case to capture rules such as {others} -> {1 item}
for removed in itertools.combinations(itemset, 1):
for removed in H_1:

# Compute the left hand side
remaining = set(itemset).difference(set(removed))
Expand All @@ -354,10 +357,11 @@ def count(itemset):
count(removed),
num_transactions,
)
# otherwise, remove the 1-item rhs from H_1, since no larger rhs with that item in it will have high
# enough confidence.
else:
H_1.remove(removed)

# Generate combinations to start off of. These 1-combinations will
# be merged to 2-combinations in the function `_ap_genrules`
H_1 = list(itertools.combinations(itemset, 1))
yield from _ap_genrules(itemset, H_1, itemsets, min_confidence, num_transactions)

if verbosity > 0:
Expand Down