Cross Validated Classification Tree Contingency Table

1 vue (au cours des 30 derniers jours)
shane
shane le 14 Oct 2013
Réponse apportée : Ilya le 16 Oct 2013
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?

Réponse acceptée

Ilya
Ilya le 16 Oct 2013
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)

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by