Shi-Lixin / Machine-Learning-Algorithms

Python实现经典分类回归、关联分析、聚类以及推荐算法等
205 stars 76 forks source link

apriori算法报错 #4

Open yongzhuo opened 4 years ago

yongzhuo commented 4 years ago

将输入数据改为如下形式(l5改为l10),报错:

datas =   [['l1', 'l2', 'l5'], ['l2', 'l4'], ['l2', 'l3'],
                    ['l1', 'l2', 'l4'], ['l1', 'l3'], ['l2', 'l3'],
                    ['l1', 'l3'], ['l1', 'l2', 'l3', 'l5'],
                    ['l1', 'l2', 'l3'], ['l1', 'l2', 'l10'],]

报错信息如下:

text_datas ok !
Traceback (most recent call last):
  File "association/apriori.py", line 234, in <module>
    AP.fit(text_datas)
  File "association/apriori.py", line 149, in fit
    self.apriori_fre_itemset()
  File "association/apriori.py", line 54, in apriori_fre_itemset
    ck_1 = self.fre_list[i - 1]
IndexError: list index out of range