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

Function stumpClassify

AdaBoost/ROC.py:31–47  ·  view source on GitHub ↗

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

(dataMatrix,dimen,threshVal,threshIneq)

Source from the content-addressed store, hash-verified

29 return dataMat, labelMat
30
31def stumpClassify(dataMatrix,dimen,threshVal,threshIneq):
32 """
33 单层决策树分类函数
34 Parameters:
35 dataMatrix - 数据矩阵
36 dimen - 第dimen列,也就是第几个特征
37 threshVal - 阈值
38 threshIneq - 标志
39 Returns:
40 retArray - 分类结果
41 """
42 retArray = np.ones((np.shape(dataMatrix)[0],1)) #初始化retArray为1
43 if threshIneq == 'lt':
44 retArray[dataMatrix[:,dimen] <= threshVal] = -1.0 #如果小于阈值,则赋值为-1
45 else:
46 retArray[dataMatrix[:,dimen] > threshVal] = -1.0 #如果大于阈值,则赋值为-1
47 return retArray
48
49
50def buildStump(dataArr,classLabels,D):

Callers 1

buildStumpFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected