【发布时间】:2018-02-13 20:33:48
【问题描述】:
我有一个非常简单的 MATLAB 程序用于训练和测试回归树,我使用教程示例中的相同数据 carsmall:
clear all
clc
close all
load carsmall
X = [Cylinders, Weight, Horsepower, Displacement];
Y = MPG;
tree = fitrtree(X,Y, 'PredictorNames',{'Cylinders', 'Weight', 'Horsepower', 'Displacement'},'ResponseName','MPG','MinLeaf',10);
Xtest=[6,4100,150,130];
MPGest = predict(tree, Xtest);
结果是 MPGest=14.9167
我想知道 predict 函数是如何得出该值的,通常是为了理解我在函数内部逐行执行。这个非常棘手,因为使用类,所以我到达了这一行
node = findNode(this.Impl,X,this.DataSummary.CategoricalPredictors,subtrees);
在那个函数里面我到达了
n = classreg.learning.treeutils.findNode(X,...
subtrees,this.PruneList,...
this.Children',iscat,...
this.CutVar,this.CutPoint,this.CutCategories,...
this.SurrCutFlip,this.SurrCutVar,...
this.SurrCutPoint,this.SurrCutCategories,...
verbose);
当我尝试进入这一步时,它只给我 n=10,MATLAB 是如何得出这个数字的?例如,如果我想编写自己的程序来使用树对象作为输入而不使用预测来计算这个数字?
【问题讨论】:
标签: matlab tree predict regression-testing