Need Predictor Importance in Random Forest Expressed as a Percentage

3 ビュー (過去 30 日間)
CMatlabWold
CMatlabWold 2021 年 3 月 25 日
コメント済み: CMatlabWold 2021 年 4 月 9 日
Hi. I'm running a code to see the importance of demographics (Predictors) on my response (Complaints). I need to express the importance as percentage, as a scale of 0 to 1 (or 0% to 100%). This is the figure I am getting is attached as "RF Importance Chart". My predictors data is attached as "PredictorsOnly.xlsx" and my response data is attached as "TotalComplaintsRF.xlsx"
X = readtable('PredictorsOnly.xlsx','PreserveVariableNames',true)
Y = readtable('TotalComplaintsRF.xlsx','PreserveVariableNames',true)
t = templateTree('NumVariablesToSample','all',...
'PredictorSelection','interaction-curvature','Surrogate','on');
rng(1); % For reproducibility
Mdl = fitrensemble(X,Y,'Method','Bag','NumLearningCycles',200, ...
'Learners',t);
yHat = oobPredict(Mdl);
R2 = corr(Mdl.Y,yHat)^2
impOOB = oobPermutedPredictorImportance(Mdl);
figure
bar(impOOB)
title('Unbiased Predictor Importance Estimates')
xlabel('Predictor variable')
ylabel('Importance')
h = gca;
h.XTickLabel = Mdl.PredictorNames;
h.XTickLabelRotation = 45;
h.TickLabelInterpreter = 'none';

採用された回答

Pratyush Roy
Pratyush Roy 2021 年 4 月 9 日
Hi,
oobPermutedPredictorImportance normalizes the predictor importance by the standard error (this is common practice in the field), therefore values are not strictly scaled between 0 and 1. However one can rescale predictor importance, for example:
imp(imp<0) = 0;
imp = imp./sum(imp);
Hope this helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by