Cross Validated Classification Tree Contingency Table
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Trees 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!