How plot a matrix for Naive Bayes classifier?

5 vues (au cours des 30 derniers jours)
Bajdar Nour
Bajdar Nour le 20 Sep 2018
Commenté : Bajdar Nour le 22 Sep 2018
I want to illustrate the matrix as shown in the picture
this is a part of the code
fh = figure('Name', 'Confusion matrix', ...
'NumberTitle', 'off');
plotmat(cMat1, 'k', 'k', 15);
title(['Classification rate: ' num2str(classificationrate) '% for Naive Bayes Classifier'], 'FontSize', 14);
but it says Undefined function or variable 'plotmat'.
does has
any function instead plotmat?
  2 commentaires
Brendan Hamm
Brendan Hamm le 20 Sep 2018
Try heatmap or imagesc.
Bajdar Nour
Bajdar Nour le 21 Sep 2018
Dear @Brendan, but when I use heatmap it gives this
Cannot find an exact (case-sensitive) match for 'heatmap'
The closest match is: HeatMap in C:\Program Files\MATLAB\MATLAB Production Server\R2015a\toolbox\bioinfo\microarray\@HeatMap\HeatMap.m

Connectez-vous pour commenter.

Réponse acceptée

Brendan Hamm
Brendan Hamm le 21 Sep 2018
The heatmap function was introduced in 2017a. The imagesc function will work though. To display the numeric counts you will require a little more work with the text function requiring the location of the text and the x-y data points where the text should appear.
A = randi([0,20],5,5);
imagesc(A);
% Find the x, y locations for the text
x = 1:size(A,2);
y = 1:size(A,1);
% Grid of X,Y locations:
[X,Y] = meshgrid(x,y);
% Convert numbers in matrix to cell array of chars
c = cellfun(@num2str,num2cell(A),'UniformOutput',false);
% Palce text labels at X,Y lcoations:
text(X(:),Y(:),c(:),'HorizontalAlignment','center');
% Add a colorbar
colorbar
This is basically what heatmap does by default, so upgrading makes things quite a bit easier.
  1 commentaire
Bajdar Nour
Bajdar Nour le 22 Sep 2018
thanks, I solved my problem

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by