フィルターのクリア

Generate confusion matrix with data out of an excel file

41 ビュー (過去 30 日間)
Eren
Eren 2023 年 12 月 3 日
回答済み: Pratyush Swain 2023 年 12 月 10 日
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 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 12 月 3 日
See confusionmat (requires Stats and ML Toolbox)

サインインしてコメントする。

回答 (1 件)

Pratyush Swain
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.

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by