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

Is it a error in aprioriGen? #14

Open
brisksea opened this issue Apr 12, 2020 · 0 comments
Open

Is it a error in aprioriGen? #14

brisksea opened this issue Apr 12, 2020 · 0 comments

Comments

@brisksea
Copy link

brisksea commented Apr 12, 2020

In chapter 11

def aprioriGen(Lk, k): #creates Ck
    retList = []
    lenLk = len(Lk)
    for i in range(lenLk):
        for j in range(i+1, lenLk): 
            L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2]
            L1.sort(); L2.sort()
            if L1==L2: #if first k-2 elements are equal
                retList.append(Lk[i] | Lk[j]) #set union
    return retList

I think the L1 and L2 should sort first, then extract the front k-2 items to compare. Take the example:
L1 = [1,2]
L2 = {3, 1}
Though, when a set converted to a list, it's usually sorted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant