求助!同样的代码换了数据集运行就没反应了!
哪位大神帮忙看一下,非常感谢!
利用python实现关联分析,同样的代码但用不同的数据集以后就运行无反应。
代码如下:
"""
Created on Sun Nov 26 17:00:38 2017
@author: Q
"""
import numpy as np
def loadDataSet():
return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]
def createC1(dateSet):
c1 = []
for line in dateSet:
for item in line:
if not [item] in c1:
c1.append([item])
c1.sort()
return list(map(frozenset,c1))
def scanData(data,ck,minSupport):#寻找满足最小支持度的项集
ssCnt = {}
for tid in data:
for can in ck:
if can.issubset(tid):
if can not in ssCnt.keys():
ssCnt[can] = 0
ssCnt[can] += 1
numItems = len(data)
retList = []
supportData = {}
for key in ssCnt.keys():
support = ssCnt[key]/