viewboundary

Show decision boundaries of classification tree in feature space.
300 Downloads
Updated 7 Jul 2015

View License

H = viewboundary(TREE) returns the handle to a figure
containing a visualization of the decision boundaries for the
classification tree TREE.

H = viewboundary(TREE,'PARAM1',VALUE1,'PARAM2',VALUE2,...) specifies
optional parameter name-value pairs:
'Beta' Scalar constant used to brighten decision boundary
regions compared to data points. Values may range from
0 to 1. Default is 0.9.
'Colors' An N-by-3 array of RGB colors for each of N classes.
Default colors are {red,blue,green,black} for N<=4 and
parula(N) for N>4.
'Legend' Turn the legend 'on' (default) or 'off'.
'LineColor' Color of decision boundary lines. Can be a 1x3 numeric
vector or a single character from the following list:
'krgybmcw'. Default is [0 0 0] (black).
'Resolution'Scalar factor determining the resolution of the
decision boundary image. Typical values range from 0 to
1. Higher values yield thicker boundary lines. Default
is 0.0075.
'XData' A floating-point vector corresponding to the first
feature of data to be plotted with the decision
boundaries. XData and YData must have the same length.
Default is an empty array.
'XLabel' Text string for x-axis label. Default is tree.PredictorNames{1}.
'XLim' Minimum and maximum x-axis limits, specified as a
two-element vector of the form [min max].
'XLimMode' Selection mode for the x-axis limits, which can either
be 'auto' (default) or 'manual'. The 'auto' setting
computes limits based on the XData provided. If the
user provides 'XLim', this property is automatically
set to 'manual'.
'XTickNum' Number of tick labels to use for x-axis. Default is 6.
'YData' A floating-point vector corresponding to the second
feature of data to be plotted with the decision
boundaries. XData and YData must have the same length.
Default is an empty array.
'YLabel' Text string for y-axis label. Default is tree.PredictorNames{2}.
'YLim' Minimum and maximum y-axis limits, specified as a
two-element vector of the form [min max].
'YLimMode' Selection mode for the y-axis limits, which can either
be 'auto' (default) or 'manual'. The 'auto' setting
computes limits based on the YData provided. If the
user provides 'YLim', this property is automatically
set to 'manual'.
'YTickNum' Number of tick labels to use for y-axis. Default is 6.
'ZData' Class labels, specified as a numeric vector,
categorical vector, logical vector, character array, or
cell array of strings. Each row of YData represents the
classification of the corresponding row of XData.
Default is an empty array.

Example 1: Show decision boundaries on part of Fisher's iris dataset.

load fisheriris
ctree = fitctree(meas(:,1:2), species,'PredictorNames',{'SL','SW'})
h = viewboundary(ctree,...
'Resolution',0.04,...
'XData',meas(:,1),...
'YData',meas(:,2),...
'ZData',species);

Important note:

This function is specifically designed for classification problems
involving data with two real-valued features.

Cite As

Matthew Eicholtz (2024). viewboundary (https://www.mathworks.com/matlabcentral/fileexchange/52003-viewboundary), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

Revised name and summary.

1.1.0.0

Updated description and image.

1.0.0.0