Cross Validated Classification Tree Contingency Table

1 回表示 (過去 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 Center および File ExchangeClassification Trees についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by