How do I make the results of a boosted classification tree reproducible?

1 次查看(过去 30 天)
I am trying to use fitcensemble to design a boosted classification tree. I have 11 classifiers and about 1000 observations. Here is my codre:
rng(1);%For reproducability
t = templateTree('Reproducible',true);
LTAFtreeBoost=fitcensemble(cleanTable(trainingRows,2:n),formula,...
'Learners',t,'OptimizeHyperparameters','auto','Cost',costMatrix,...
'NumLearningCycles',100)
figure;bar(categorical(LTAFtreeBoost.PredictorNames),predictorImportance(LTAFtreeBoost))
title('Predictor Importance');
The problem is, I get a different classifier every time I run the code. I need to be able to change other parts of my script and not have the classifier change. Any suggestions?

回答(1 个)

Drew
Drew 2022-10-18
The different results are likely coming from randomization in the hyperparameter optimization. https://www.mathworks.com/help/stats/fitcensemble.html
If you would like to get the same classifer every time, then don't run hyperparameter optimization every time. Call fitcensemble with the particular parameters desired for your final model.

类别

Help CenterFile Exchange 中查找有关 Classification 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by