MCPcopy Index your code
hub / github.com/wepe/MachineLearning / getNumLeafs

Function getNumLeafs

DecisionTree/treePlotter.py:14–22  ·  view source on GitHub ↗
(myTree)

Source from the content-addressed store, hash-verified

12arrow_args = dict(arrowstyle="<-")
13
14def getNumLeafs(myTree):
15 numLeafs = 0
16 firstStr = myTree.keys()[0]
17 secondDict = myTree[firstStr]
18 for key in secondDict.keys():
19 if type(secondDict[key]).__name__=='dict':#test to see if the nodes are dictonaires, if not they are leaf nodes
20 numLeafs += getNumLeafs(secondDict[key])
21 else: numLeafs +=1
22 return numLeafs
23
24def getTreeDepth(myTree):
25 maxDepth = 0

Callers 2

plotTreeFunction · 0.85
createPlotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected