主要内容

view

View regression tree

Syntax

查看(树)
查看(树,名称,值)

描述

view()返回的文本描述,决策树。

view(,Name,Value)describes有一个或多个指定的其他选项Name,Value配对参数。

Input Arguments

由回归树或紧凑的回归树创建fitrtree或者袖珍的.

Name-Value Arguments

将可选的参数对Name1=Value1,...,NameN=ValueN, whereNameis the argument name and价值是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

模式

Display of, either'graph'或者'文本'.'graph'opens a GUI displaying, and containing controls for querying the tree.'文本'sends output to the Command Window describing.

Default:'文本'

例子

expand all

查看训练有素的回归树的文本和图形显示。

加载汽车舞data set. Consider a model that explains a car's fuel economy (MPG) using its weight (Weight)和圆柱数(Cylinders).

load汽车舞X = [Weight Cylinders]; Y = MPG;

Train a regression tree using all measurements.

MDL= fitrtree(X,Y);

查看训练有素的回归树的文本显示。

view(Mdl)
回归1的决策树如果x1 <3085.5,则节点2 elseif x1> = 3085.5然后节点3 else 3 else 23.7181 2如果x1 <2371然后node 4 elseif x1> = 2371然后node 5 else 5 else 28.7931 3 if x2 <7 in If x2 <7 if nif node node node 6 elsif x2 elsif x2 elseif x2>=7 then node 7 else 15.5417 4 if x1<2162 then node 8 elseif x1>=2162 then node 9 else 32.0741 5 if x2<5 then node 10 elseif x2>=5 then node 11 else 25.9355 6 fit = 19.2778 7 if然后x1 <4381然后节点12 elseif x1> = 4381然后节点13 else 14.2963 8如果x1 <1951然后node 14 elseif x1> = 1951然后node 15 else 15 else 33.3056 9 fit = 29.6111 10 If x1 <2827.5 then then then n then n then node node x1> x1> = x1> = = = = = = = = = = = = = = 29.6111 102827.5然后节点17其他27.2143 11如果x1 <3013.5然后节点18 elseif x1> = 3013.5然后节点19其他23.25 12如果x1 <3533.5然后node node node 20 elsif x1> = 3533.5然后节点21 else 14.8696 14.8696 13 fit = 11 14 fit = 29.375 fit = 29.37515如果x1 <2142.5然后节点22 elseif x1> = 2142.5然后节点23 else 34.4286 16如果x1 <2385,则节点24 elseif x1> = 2385然后节点25 else 27.6389 17 fit = 24.66667= 16.6 21如果x1 <4378,则节点26 elseif x1> = 4378然后节点27其他14.3889 22如果x1 <2080然后节点28 elseif x1> = 2080然后节点29 else 29 else 34.8333 23 fit = 32 24 fit = 32 24 fit = 24.5 25如果x1 <2412.5然后node node node node node 30 eseif x1> = 2412.5,则节点31其他28.0313 26如果x1 <4365然后节点32 elseif x1> = 4365然后节点33 else 33 else 14.2647 27 fit = 16.5 28 fit = 34.125 29 fit = 34.125 29 fit = 36.25 30 fit = 34 fit = 34 31 fit = 34 31 if x1 <2447然后node node 34 elseif x1> = x1> = = 34 seles x1> = = = 34 seles x1> =2447然后节点35其他27.6333 32如果如果x1 <4122.5,则节点36 elseif x1> = 4122.5然后节点37其他14.5313 33 fit = 10 34 fit = 10 34 fit = 24 35如果x1 <2573.5然后node 38 Elsif x1> = 2573.5然后Node x1> = 2573.5,然后node 39 els Node 39其他27.88992936如果x1 <3860,则节点40 elseif x1> = 3860,然后节点41 else 14.15 37 fit = 15.1667 38 fit = 27.125 39如果x1 <2580,则节点42 elsif x1> = 2580然后node node 43 else node 43 else 28.2 40 fit = 14.5 41 fit = 14.5 41 fit = 14.5 41 fit = 14.5 41 fit = 14.5 41= 13.625 42 fit = 31 43 fit = 27.8889

View graphical display of the trained regression tree.

view(Mdl,“模式”,'graph');

图回归树查看器包含一个轴对象和uimenu类型的其他对象。轴对象包含69个类型行的对象,文本。

加载汽车舞data set. Consider a model that explains a car's fuel economy (MPG) using its weight (Weight)和圆柱数(Cylinders).

load汽车舞X = [Weight Cylinders]; Y = MPG;

Grow a bag of 100 regression trees using all measurements.

rng(1)%可再现性mdl = treebagger(100,x,y);

或者,您可以使用fitrensemble种植一袋回归树。

MDLis aTreeBaggermodel object.MDL.Treesstores the bag of 100 trained regression trees in a 100-by-1 cell array. That is, each cell inMDL.Treescontains aCompactregressionTreemodel object.

View a graph of the 10th regression tree in the bag.

tree10 = mdl.trees {10};查看(树10,“模式”,'graph');

Figure Classification tree viewer contains an axes object and other objects of type uimenu, uicontrol. The axes object contains 153 objects of type line, text.

默认,the software grows deep trees for bags of trees.

加载汽车舞data set. Consider a model that explains a car's fuel economy (MPG) using its weight (Weight)和圆柱数(Cylinders).

load汽车舞X = [Weight Cylinders]; Y = MPG;

Boost an ensemble of 100 regression trees using all measurements.

mdl = fitrensemble(x,y,'Method','LSBoost');

MDLis a回归Ensemblemodel object.MDL。训练将100个训练有素的回归树的合奏存储在100 x-1的单元阵列中。也就是说,每个单元格MDL。训练contains aCompactregressionTreemodel object.

查看合奏中第10个回归树的图。

tree10 = mdl。训练{10};查看(树10,“模式”,'graph');

图回归树查看器包含一个轴对象和uimenu类型的其他对象。The axes object contains 36 objects of type line, text.

默认,fitrensemble生长浅树,以增强树的合奏。那是,“学习者”istemplateTree (MaxNumSplits, 10).

提示

查看树tfrom an ensemble of trees, enter one of these lines of code

view(Ens.Trained{t})view(Bag.Trees{t})

To savein the Command Window, get a figure handle by using thefindallsetdiff功能,然后保存使用该功能另存为.

之前= findall(groot,'Type','数字');% Find all figuresview(Mdl,“模式”,'graph')之后= findall(groot,'Type','数字');h = setDiff(在之前,之前);% Get the figure handle of the tree viewer另存为(h,'a.png')

Extended Capabilities

See Also

|