《机器学习实战》Chapter 3 决策树 python3.7代码勘误
错误1:TypeError: ‘dict_keys’ object is not subscriptable
这是因为在python3中keys不允许切片,先转List再切片就好了只要将以下几行代码:
line14 line24 line46:firstStr = myTree.keys()[0]
改为:
firstStr = list(myTree.keys())[0] 即可。
具体的代码及数据文件可以到我的github来看:
https://github.com/crazyqiqi0639/Machine-Learning-in-Action-codes-and-problems.git