nodeVariableRange
Syntax
Description
also specifies whether to omit the unused predictor variables from the returned
varRange
= nodeVariableRange(tree
,nodeID
,OmitUnusedVariables=omitUnusedVars
)varRange
.
Examples
Variable Range of Decision Tree Node
Create a decision tree for classification, and retrieve the range of variables at a specified node of the decision tree.
Load the census1994
data set. The table adultdata
contains six numeric and eight categorical variables.
load census1994
Train a classification tree based on the features contained in adultdata
and the class labels in adultdata.salary
. Limit the number of splits in the tree by specifying the name-value argument MaxNumSplits
.
tree = fitctree(adultdata,"salary",MaxNumSplits=31)
tree = ClassificationTree PredictorNames: {'age' 'workClass' 'fnlwgt' 'education' 'education_num' 'marital_status' 'occupation' 'relationship' 'race' 'sex' 'capital_gain' 'capital_loss' 'hours_per_week' 'native_country'} ResponseName: 'salary' CategoricalPredictors: [2 4 6 7 8 9 10 14] ClassNames: [<=50K >50K] ScoreTransform: 'none' NumObservations: 32561
tree
is a trained ClassificationTree
model for classification.
View the graphical display of the trained classification tree.
view(tree,Mode="graph")
Retrieve the range of predictor variables at node 10.
varRange = nodeVariableRange(tree,10)
varRange = struct with fields:
age: [-Inf 20.5000]
relationship: [Not-in-family Other-relative Own-child Unmarried]
capital_gain: [7.0735e+03 Inf]
Input Arguments
tree
— Decision tree model
ClassificationTree
object | CompactClassificationTree
object | RegressionTree
object | CompactRegressionTree
object
Decision tree model, specified as one of the following:
ClassificationTree
object returned byfitctree
CompactClassificationTree
object returned by theClassificationTree
object functioncompact
RegressionTree
object returned byfitrtree
CompactRegressionTree
object returned by theRegressionTree
object functioncompact
nodeID
— Node in decision tree
positive integer scalar
Node in the decision tree, specified as a positive integer scalar.
nodeID
must be less than or equal to the number of nodes in the
decision tree.
Data Types: single
| double
omitUnusedVars
— Indicator to omit unused predictor variables
true
or 1
(default) | false
or 0
Indicator to omit unused predictor variables from varRange
,
specified as a numeric or logical 1
(true
) or
0
(false
).
Output Arguments
varRange
— Variable range at decision tree node
structure
Variable range at the decision tree node, returned as a structure. If a predictor
variable is numeric, the corresponding field of varRange
is a
1-by-2 numeric vector containing the lower and upper bounds. If a predictor variable is
categorical, the corresponding field of varRange
is a categorical
array containing the categories subgroup.
Extended Capabilities
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2020a
See Also
ClassificationTree
| CompactClassificationTree
| RegressionTree
| CompactRegressionTree
| fitctree
| fitrtree
| view
| view
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)