# view

Class: CompactRegressionTree

View tree

## Syntax

`view(tree)view(tree,Name,Value)`

## Description

`view(tree)` returns a text description of `tree`, a decision tree.

`view(tree,Name,Value)` describes `tree` with additional options specified by one or more `Name,Value` pair arguments.

## Input Arguments

 `tree` A regression tree or compact regression tree created by `fitrtree` or `compact`.

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside single quotes (`' '`). You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

 `'Mode'` String describing the display of `tree`, either `'graph'` or `'text'`. `'graph'` opens a GUI displaying `tree`, and containing controls for querying the tree. `'text'` sends output to the Command Window describing `tree`. Default: `'text'`

## Examples

View a regression tree for the `carsmall` data in both textual and graphical displays:

```load carsmall tree = fitrtree([Weight, Cylinders],MPG,... 'categoricalpredictors',2,'MinParent',20,... 'PredictorNames',{'W','C'}); view(tree) Decision tree for regression 1 if W<3085.5 then node 2 elseif W>=3085.5 then node 3 else 23.7181 2 if W<2371 then node 4 elseif W>=2371 then node 5 else 28.7931 3 if C=8 then node 6 elseif C in {4 6} then node 7 else 15.5417 4 if W<2162 then node 8 elseif W>=2162 then node 9 else 32.0741 5 if C=6 then node 10 elseif C=4 then node 11 else 25.9355 6 if W<4381 then node 12 elseif W>=4381 then node 13 else 14.2963 7 fit = 19.2778 8 fit = 33.3056 9 fit = 29.6111 10 fit = 23.25 11 if W<2827.5 then node 14 elseif W>=2827.5 then node 15 else 27.2143 12 if W<3533.5 then node 16 elseif W>=3533.5 then node 17 else 14.8696 13 fit = 11 14 fit = 27.6389 15 fit = 24.6667 16 fit = 16.6 17 fit = 14.3889 view(tree,'Mode','graph')```

## See Also

Was this topic helpful?

Get trial now