MCPcopy Create free account
hub / github.com/Jack-Cherish/Machine-Learning / stumpClassify

Function stumpClassify

AdaBoost/adaboost.py:55–71  ·  view source on GitHub ↗

单层决策树分类函数 Parameters: dataMatrix - 数据矩阵 dimen - 第dimen列,也就是第几个特征 threshVal - 阈值 threshIneq - 标志 Returns: retArray - 分类结果

(dataMatrix,dimen,threshVal,threshIneq)

Source from the content-addressed store, hash-verified

53 plt.show()
54
55def stumpClassify(dataMatrix,dimen,threshVal,threshIneq):
56 """
57 单层决策树分类函数
58 Parameters:
59 dataMatrix - 数据矩阵
60 dimen - 第dimen列,也就是第几个特征
61 threshVal - 阈值
62 threshIneq - 标志
63 Returns:
64 retArray - 分类结果
65 """
66 retArray = np.ones((np.shape(dataMatrix)[0],1)) #初始化retArray为1
67 if threshIneq == 'lt':
68 retArray[dataMatrix[:,dimen] <= threshVal] = -1.0 #如果小于阈值,则赋值为-1
69 else:
70 retArray[dataMatrix[:,dimen] > threshVal] = -1.0 #如果大于阈值,则赋值为-1
71 return retArray
72
73
74def buildStump(dataArr,classLabels,D):

Callers 2

buildStumpFunction · 0.70
adaClassifyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected