MCPcopy Index your code
hub / github.com/apachecn/ailearning / createForeCast

Function createForeCast

src/python/9.RegTrees/regTrees.py:377–394  ·  view source on GitHub ↗

Desc: 调用 treeForeCast ,对特定模型的树进行预测,可以是 回归树 也可以是 模型树 Args: tree -- 已经训练好的树的模型 inData -- 输入的测试数据 modelEval -- 预测的树的模型类型,可选值为 regTreeEval(回归树) 或 modelTreeEval(模型树),默认为回归树 Returns: 返回预测值矩阵

(tree, testData, modelEval=regTreeEval)

Source from the content-addressed store, hash-verified

375
376# 预测结果
377def createForeCast(tree, testData, modelEval=regTreeEval):
378 """
379 Desc:
380 调用 treeForeCast ,对特定模型的树进行预测,可以是 回归树 也可以是 模型树
381 Args:
382 tree -- 已经训练好的树的模型
383 inData -- 输入的测试数据
384 modelEval -- 预测的树的模型类型,可选值为 regTreeEval(回归树) 或 modelTreeEval(模型树),默认为回归树
385 Returns:
386 返回预测值矩阵
387 """
388 m = len(testData)
389 yHat = mat(zeros((m, 1)))
390 # print yHat
391 for i in range(m):
392 yHat[i, 0] = treeForeCast(tree, mat(testData[i]), modelEval)
393 # print "yHat==>", yHat[i, 0]
394 return yHat
395
396
397if __name__ == "__main__":

Callers 1

regTrees.pyFile · 0.85

Calls 1

treeForeCastFunction · 0.85

Tested by

no test coverage detected