matrix dimension must agree
Afficher commentaires plus anciens
Hi,
I am trying to do CKNN. The script runs smoothly at first. But when I try to see confusion matrix, Iget error saying Matrix dimension must agree.
Why is this happenning?
load('Assignment 2\ENN543_Assignment2_Data\Q3\mnist_train.mat')
mnist_images_train = reshape(imgs,1024,50000);
mnist_train_y = labels;
load('Assignment 2\ENN543_Assignment2_Data\Q3\mnist_test.mat')
mnist_images_test = reshape(imgs,1024,10000);
mnist_test_y=labels;
load("Assignment 2\ENN543_Assignment2_Data\Q3\svhn_test.mat")
svnh_images_test=reshape(imgs,1024,26032);
svnh_test = labels;
%%-CKNN
% cknn = fitcknn(mnist_images_train',categorical(mnist_train_y), 'Distance', 'cityblock');
cknn = fitcknn(mnist_images_train',mnist_train_y,'NumNeighbors',5);
pred = cknn.predict(mnist_images_test')
disp(sum(pred == mnist_test_y)/length(mnist_test_y))
%%Matrix dimension must agree
confusionchart(mnist_test_y, pred)
1 commentaire
Ajay Pattassery
le 1 Nov 2019
can you post the output of size(mnist_test_y) and size(pred)
Réponses (0)
Catégories
En savoir plus sur Statistics and Machine Learning Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!