Plotconfusion Matrix if targets and labels are in cell

5 ビュー (過去 30 日間)
Marek Ziak
Marek Ziak 2019 年 11 月 28 日
コメント済み: Marek Ziak 2019 年 12 月 7 日
Hello everyone,
I would like to ask how it is possible to plot confusion matrix if my data from the network and targets are in cell arrays. I tried converting them to categorical type but it wasn't really helpful. Cell array is 1x1000 and every cell is 1x6. I appreciate any help.
Thanks
Marek

採用された回答

Raunak Gupta
Raunak Gupta 2019 年 12 月 4 日
Hi,
Directly converting from cell array to categorical in which the contents of cell array also represents a cell array is not supported. Instead it can be converted to a matrix by atleast looping over the number of datapoints that are there. I am assuming that the {1x6} cell array is one-hot encoded (all 6 values should sum up to 1) as it’s a classification problem.
% For example target is 1x5 cell array containing 1x3 cell arrays.
targets = {{1,0,0},{0,1,0},{1,0,0},{1,0,0},{0,0,1}};
predicted = {{1,0,0},{1,0,0},{0,1,0},{1,0,0},{0,0,1}};
target_matrix = zeros(size(targets{1},2),size(targets,2));
predicted_matrix = zeros(size(predicted{1},2),size(predicted,2));
for i=1:size(targets,2)
target_matrix(:,i) = cell2mat(targets{i});
end
for i=1:size(predicted,2)
predicted_matrix(:,i) = cell2mat(predicted{i});
end
plotconfusion(target_matrix,predicted_matrix);
  1 件のコメント
Marek Ziak
Marek Ziak 2019 年 12 月 7 日
Hi thank you so much for your answer. It is working.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by