这周学习了数据挖掘中计算频繁项集的aprioir算法,
老师让用python实现一下,自己按照《数据挖掘概念与技术》第六章上面讲解的过程实现
如果有大佬发现问题,欢迎提出意见
实现如下
"""
aprioir算法
@author: liuyinxin
"""
# 设置支持度为2
support = 2
def load_data():
"""
:return: 加载数据
"""
data = []
with open('test_data.txt', 'r') as f:
while True:
line = f.readline()
if not line:
break
data.append([int(_) for _ in line.split()])
return data
def freq_1_items(data, sup=2):
"""
找到1频繁项集
:param
:return:
"""
L = {
}
for item in data:
for i in item:
if i not in L: