mirror of
https://gitee.com/TheAlgorithms/Statistical-Learning-Method_Code.git
synced 2024-12-22 12:48:55 +08:00
This commit is contained in:
parent
02f06e22db
commit
77ef3af1c0
@ -128,12 +128,8 @@ def calcBestFeature(trainDataList, trainLabelList):
|
||||
:return: 信息增益最大的特征及最大信息增益值
|
||||
'''
|
||||
#将数据集和标签集转换为数组形式
|
||||
#trainLabelArr转换后需要转置,这样在取数时方便
|
||||
#例如a = np.array([1, 2, 3]); b = np.array([1, 2, 3]).T
|
||||
#若不转置,a[0] = [1, 2, 3],转置后b[0] = 1, b[1] = 2
|
||||
#对于标签集来说,能够很方便地取到每一位是很重要的
|
||||
trainDataArr = np.array(trainDataList)
|
||||
trainLabelArr = np.array(trainLabelList).T
|
||||
trainLabelArr = np.array(trainLabelList)
|
||||
|
||||
#获取当前特征数目,也就是数据集的横轴大小
|
||||
featureNum = trainDataArr.shape[1]
|
||||
|
Loading…
Reference in New Issue
Block a user