Extracting data from confusion matrix fig
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi, How can i extract the data from a confusion matrix fig file?
댓글 수: 3
Bala Tripura Bodapati
2022년 5월 26일
Hi Umair,
Could you specify whether the figure contains confusion matrix or confusion chart? Also could you specify what type of data do you want to extract specifically? Attaching an example would help me answer your query with more specificity.
답변 (2개)
Chunru
2022년 5월 26일
편집: Chunru
2022년 5월 26일
f = openfig('SqueezeNet-CM', 'visible');
h = findobj(f.Children(2).Children, 'Type', 'Text');
data = zeros(length(h), 1);
for i=1:length(h)
data(i) = sscanf(h(i).String, '%f');
end
m = 5;
data = reshape(data, [2*m m]);
data_number = data(4:2:end, 2:end)
data_number = data_number(end:-1:1, end:-1:1)
댓글 수: 0
Bala Tripura Bodapati
2022년 5월 26일
Hi Umair,
It is my understanding that you would like to extract the numeric values from confusion matrix plotted on a figure.
From the confusion matrix plotted using 'plotconfusion' function, there is no method to extract the numeric values.
Alternatively, you can plot the confusion matrix using the 'confusionchart' function on a figure and then extract the numeric values.
The following code illustrates the same:
load fisheriris
X = meas;
Y = species;
Mdl = fitcknn(X,Y,'NumNeighbors',5,'Standardize',1);
predictedY = resubPredict(Mdl);
fig=figure;
confusionchart(Y,predictedY);
'cm' is a confusion chart object. The 'NormalizedValues' property of this object outputs the numeric matrix:
matrix=cm.NormalizedValues
Also, refer the confusionchart documentation for more information on confusion chart and graphics hierarchy documentation for more information on accessing figure object and it's children.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!