compact
Compact regression tree
Syntax
Description
Examples
Reduce Memory Consumption of Regression Tree Model
Compare the size of a full regression tree model to the compacted model.
Load the carsmall
data set. Consider Acceleration
, Displacement
, Horsepower
, and Weight
as predictor variables.
load carsmall
X = [Acceleration Cylinders Displacement Horsepower Weight];
Grow a regression tree using the entire data set.
Mdl = fitrtree(X,MPG)
Mdl = RegressionTree ResponseName: 'Y' CategoricalPredictors: [] ResponseTransform: 'none' NumObservations: 94
Mdl
is a RegressionTree
model. It is a full model, that is, it stores information such as the predictor and response data fitrtree
used in training. For a properties list of full regression tree models, see RegressionTree
.
Create a compact version of the full regression tree—that is, one that contains enough information to make predictions only.
CMdl = compact(Mdl)
CMdl = CompactRegressionTree ResponseName: 'Y' CategoricalPredictors: [] ResponseTransform: 'none'
CMdl
is a CompactRegressionTree
model. For a properties list of compact regression tree models, see CompactRegressionTree
.
Inspect the amounts of memory that the full and compact regression trees consume.
mdlInfo = whos('Mdl'); cMdlInfo = whos('CMdl'); [mdlInfo.bytes cMdlInfo.bytes]
ans = 1×2
12570 7067
cMdlInfo.bytes/mdlInfo.bytes
ans = 0.5622
In this case, the compact regression tree model uses approximately half the memory that the full model uses.
Input Arguments
tree
— Regression tree
RegressionTree
object
Regression tree, specified as a RegressionTree
object created by the fitrtree
function.
Output Arguments
ctree
— Compact regression tree
CompactRegressionTree
object
Compact regression tree, returned as a CompactRegressionTree
object. You can predict regressions using
ctree
exactly as you can using tree
. However,
because ctree
does not contain training data, you cannot perform some
actions, such as cross validation.
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 R2011a
See Also
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 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)