MCPcopy Create free account
hub / github.com/Jack-Cherish/Machine-Learning / classify

Function classify

Decision Tree/Decision Tree.py:358–367  ·  view source on GitHub ↗
(inputTree, featLabels, testVec)

Source from the content-addressed store, hash-verified

356 2017-07-25
357"""
358def classify(inputTree, featLabels, testVec):
359 firstStr = next(iter(inputTree)) #获取决策树结点
360 secondDict = inputTree[firstStr] #下一个字典
361 featIndex = featLabels.index(firstStr)
362 for key in secondDict.keys():
363 if testVec[featIndex] == key:
364 if type(secondDict[key]).__name__ == 'dict':
365 classLabel = classify(secondDict[key], featLabels, testVec)
366 else: classLabel = secondDict[key]
367 return classLabel
368
369"""
370函数说明:存储决策树

Callers 1

Decision Tree.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected