11、Aoriori

This commit is contained in:
wenhuanhuan
2017-03-03 15:21:38 +08:00
parent 81cee33fba
commit 80ad02982c
4 changed files with 37 additions and 1 deletions

View File

@@ -6,4 +6,4 @@
2. 项集的支持度(support):数据集中包含该项集的记录所占的比例
3. 置信度confidence):置信度({A}->{B}) = 支持度{A,B}/支持度{A}
Apriori原理如果某个项集是频繁的那么它的所有子集也是频繁的反之一个项集是非频繁的那么它的所有超集也是非频繁的
Apriori原理如果某个项集是频繁的那么它的所有子集也是频繁的反之一个项集是非频繁的那么它的所有超集也是非频繁的

View File

@@ -0,0 +1,12 @@
def loadDataSet():
return [[1,3,4],[2,3,5],[1,2,3,5],[2,5]]
def createC1(dataSet):
c1=[]
for transaction in dataSet:
for item in transaction:
if not [item] in c1:
c1.append([item])
c1.sort()
return map(frozenset,c1)
def scanD(D,ck,minSupport):
ssCnt = {}

View File

@@ -0,0 +1,19 @@
class treeNode:
def __init__(self,nameValue,numOccur,parentNode):
self.name = nameValue
self.count = numOccur
self.nodeLink = None
self.parent = parentNode
self.children = {}
def inc(self,numOccur):
self.count += numOccur
def disp(self,ind=1):
print(' '*ind,self.name,' ',self.count)
for child in self.children.values():
child.disp(ind+1)
if __name__ == "__main__":
import fpGrowth
rootNode = fpGrowth.treeNode('pyramid',9,None)
rootNode.children['eye']=fpGrowth.treeNode('eye',13,None)
rootNode.disp()

View File

@@ -0,0 +1,5 @@
class Test:
if __name__ == "__main__":
fza=frozenset(['a','bc'])
adict={fza:1,'b':2}
print(adict)