tommyod/Efficient-Apriori

sort step not needed after combinations for join_step

Closed this issue · 2 comments

bnm3k commented

In join_step, itemsets is already, or rather should be sorted. Therefore tail_items remains sorted as it's being built up in the inner for-loop.

Now, when using itertools.combinations to get a and b, there's no need to use sorted since from the Python 3 docs:

The combination tuples are emitted in lexicographic ordering according to the order of the input iterable. So, if the input iterable is sorted, the output tuples will be produced in sorted order.

My suggestion is to remove the sorted call since it's unnecessary. I've run the tests without it and they all pass. I could make a PR but first wanted to create an issue to see if I missed something.

Sounds good to me. Please create a PR if you have the time :)

bnm3k commented

I've made the PR