Retrieve the data set of out-of-bag.

조회 수: 5 (최근 30일)
秀和 髙橋
秀和 髙橋 2022년 1월 25일
답변: TED MOSBY 대략 9시간 전
Mdl = TreeBagger(NumTrees,X,Y,Name,Value)
I developed a random forest model.
I'd like to make internal validation by out-of-bag datasets before external validation.
How can I retrive the data set of out-of-bag?

답변 (1개)

TED MOSBY
TED MOSBY 대략 9시간 전
In MATLAB's ‘TreeBagger’, the out-of-bag (OOB) observations are automatically used for internal validation.
Here is how you can do adjust your code:
mdl = TreeBagger(NumTrees, X, Y, 'OOBPrediction', 'On');
If you want to explicitly retrieve the indices or data of the out-of-bag samples for each tree, you can use the ‘OOBIndices’ property of the ‘TreeBagger’ object like below:
To retrieve the indices:
oobIndices = mdl.OOBIndices; % Please note this property is is not available is R2021b, please upgrade MATLAB to leverage this
To retrieve the data:
treeIndex = 1; % Specify the tree number for which you want the OOB data
oobDataX = X(oobIndices(:, treeIndex), :);
oobDataY = Y(oobIndices(:, treeIndex), :);
Please refer to the input arguments and properties section of this link: www.mathworks.com/help/stats/treebagger.html
Hope this helps!

카테고리

Help CenterFile Exchange에서 Create System Objects에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by