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

Function getTreeDepth

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

Source from the content-addressed store, hash-verified

22 return numLeafs
23
24def getTreeDepth(myTree):
25 maxDepth = 0
26 firstStr = myTree.keys()[0]
27 secondDict = myTree[firstStr]
28 for key in secondDict.keys():
29 if type(secondDict[key]).__name__=='dict':#test to see if the nodes are dictonaires, if not they are leaf nodes
30 thisDepth = 1 + getTreeDepth(secondDict[key])
31 else: thisDepth = 1
32 if thisDepth > maxDepth: maxDepth = thisDepth
33 return maxDepth
34
35def plotNode(nodeTxt, centerPt, parentPt, nodeType):
36 createPlot.ax1.annotate(nodeTxt, xy=parentPt, xycoords='axes fraction',

Callers 1

createPlotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected