Cross Validated Classification Tree Contingency Table

조회 수: 3 (최근 30일)
shane
shane 2013년 10월 14일
답변: Ilya 2013년 10월 16일
I need the final contingency table for my cross validated classification tree. My code is:
%Create classification tree
tree = ClassificationTree.fit(x,y);
%Cross validate tree
[E,SE,Nleaf,bestlevel] = cvLoss(tree,'subtrees','all','treesize','se','kfold',5);
Which gives me a cross validated tree and E and se. But for validation I need the entire cross validated contingency table so I can compute POD, POFD, FAR.
This is how I understand it: Since it is 5 fold cross validation, 5 trees are created, each built using a random 80% of the data. These trees are then each tested with the corresponding 20% of data to compute a final E and se. What I want are the 5 contingency tables which can be created when the testing data is run through each of the 5 cross validation trees (one from each tree). I then want to sum these 5 tables into an overall final contingency table. Is it possible to access this data so I don't have to code it myself?

채택된 답변

Ilya
Ilya 2013년 10월 16일
It is not possible to access this data. However, coding is not hard. I presume you want to prune every tree to bestlevel returned by the cvLoss method. Here is how you can compute the overall confusion matrix (contingency table).
load ionosphere
cv = cvpartition(Y,'kfold',5);
Yhat = repmat(Y(1),numel(Y),1);
for k=1:5
itrain = training(cv,k);
itest = test(cv,k);
tree = ClassificationTree.fit(X(itrain,:),Y(itrain));
tree = prune(tree,'level',bestlevel);
Yhat(itest) = predict(tree,X(itest,:));
end
confusionmat(Y,Yhat)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Classification Trees에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by