第九章-树回归中:
P162后面[0]是多余的
def binSplitDataSet(dataSet, feature, value):
mat0 = dataSet[nonzero(dataSet[:,feature] > value)[0],:]
mat1 = dataSet[nonzero(dataSet[:,feature] <= value)[0],:]
return mat0,mat1
image.png
出现ValueError: Masked arrays must be 1-D 错误时,经过检查后发现
绘制散点图输入的矩阵需要转换成list
reDraw.a.scatter(reDraw.rawDat[:, 0].tolist(), reDraw.rawDat[:, 1].tolist(), s=5)
# 书上是reDraw.a.scatter(reDraw.rawDat[:, 0], reDraw.rawDat[:, 1], s=5)
网友评论