Apriori algorithem 中需要修改的一段

来源:互联网 发布:程序员 年薪 编辑:程序博客网 时间:2024/04/29 10:54

发现在前天转载的Apriori algorithem中存在一点小的瑕疵,特更正如下。

 

# Apriori algorithem
def Apriori(filename,supct):
    #get source data from file
    srcdata=getsrcdata(filename)
    # get C1
    c=getC1(srcdata)
    # L
    L={}
    LR={}
    while True:
        # temp L,if empty,over
        # while not,this is the new L
        temp_L=getL(c,supct)
        if not temp_L:
            break
        else:
            L=temp_L
            for item in temp_L.keys():
                LR[item]=temp_L[item]          ###修改之处
        # get the next candidate from pre L
        c=getnextcandi(L,srcdata)
    return LR

原创粉丝点击