第3章

1.

决策树理解比较简单,关键要自己把理论用笔实践一遍,推荐http://www.cise.ufl.edu/~ddd/cap6635/Fall-97/Short-papers/2.htm教程。自己把里面的数据用matlab或python辅助计算下。

2.

信息增益(Information Gain)和 (熵Entropy)

3.

list 3-1计算给定数据集的香农熵

for featVec in dataSet:
        currentLabel=featVec[-1]
        if currentLabel not in labelCounts.keys():
                labelCounts[currentLabel]=0   
                labelCounts[currentLabel]+=1
        else:
               labelCounts[currentLabel]+=1

#中文书上的代码执行和理解起来有歧义,建议采用上述if---else语句。
#或用原版的代码:
if currentLabel not in labelCounts.keys():labelCounts[currentLabel]=0   
labelCounts[currentLabel]+=1

  

list 3-2按照给定特征划分数据集

for featVec in dataSet 之后featVec是一个list,比如第一次循环后,featVec=[1,1,'yes'],featVec[0]是1.

原文地址:https://www.cnblogs.com/cdsj/p/3538070.html