Generate confusion matrix with data out of an excel file
27 次查看(过去 30 天)
显示 更早的评论
Hello,
I have my classifications and the true label of a data set written in an excel file. The plan ist to create with this dataset a confusion matrix. Is there a Matlab App to create the confusion matrix or any kind of code which can create this?
The table looks like this. There are 42 classes and 12630 classifications and true label. Here it is just a short outtake of the excel file.
Classification 16 1 38 33 11 38 18 12
True Label 16 1 38 33 11 38 18 12
回答(1 个)
Pratyush Swain
2023-12-10
Hi Eren,
I understand you want to read classifications and true labels of a data set from an excel file and create a confusion matrix. Please refer to the example workflow as follows:
1. Create excel sheet-
I have created an excel sheet containing the provided data.
2 - Read the excel file through 'readtable' or 'readmatrix' function
M = readmatrix('path_to_file.xlsx');
% Can also read the excel file as table through T = readtable('path_to_file.xlsx'); %
3 - Load the labels to 'confusionmat' function.(Requires Statistics and Machine Learning Toolbox to be installed)
g1 = M(:,1); % Known groups
g2 = M(:,2); % Predicted groups
[C1,order] = confusionmat(g1,g2)
% The order of labels can also be changed as required %
[C2,order] = confusionmat(g1,g2,'Order',[38,33,18,16,12,11,1])
4 - Visualize the confusion matrix as confusion chart
cm=confusionchart(C2)
For more information of 'confusionmat' and 'import spreadsheets' , please refer to:
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!