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?
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!