This commit is contained in:
Dod-o 2020-05-23 17:11:55 +08:00 committed by GitHub
parent 02f06e22db
commit 77ef3af1c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,12 +128,8 @@ def calcBestFeature(trainDataList, trainLabelList):
:return: 信息增益最大的特征及最大信息增益值 :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) trainDataArr = np.array(trainDataList)
trainLabelArr = np.array(trainLabelList).T trainLabelArr = np.array(trainLabelList)
#获取当前特征数目,也就是数据集的横轴大小 #获取当前特征数目,也就是数据集的横轴大小
featureNum = trainDataArr.shape[1] featureNum = trainDataArr.shape[1]