Skip to content

A bug need to adjust #1

Description

@wheniseeyou
def getNumleafs(myTree):
	numLeafs =0#初始化节点数
	firstSides = list(myTree.keys())#先把最广的key遍历
	firstStr = firstSides[0]#取第一个key
	secondDict = myTree[firstStr]#取第一个key的子字典

#=>Traceback (most recent call last):
  File "/Users/admin/PycharmProjects/untitled20/机器学习/决策树的实现.py", line 317, in <module>
    createPlot(myDat)
  File "/Users/admin/PycharmProjects/untitled20/机器学习/决策树的实现.py", line 98, in createPlot
    plotTree.totalW = float(getNumleafs(inTree))
  File "/Users/admin/PycharmProjects/untitled20/机器学习/决策树的实现.py", line 18, in getNumleafs
    firstSides = dict(myTree.keys())#先把最广的key遍历
AttributeError: 'list' object has no attribute 'keys'

The problem was that the PY3.5 to PY3.6 had changed the rules within the dict uses

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions