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

2 Ansichten (letzte 30 Tage)
Joe Sullivan
Joe Sullivan am 23 Jun. 2022
Beantwortet: Drew am 18 Okt. 2022
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?

Antworten (1)

Drew
Drew am 18 Okt. 2022
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.

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by