Borrar filtros
Borrar filtros

matrix dimension must agree

2 visualizaciones (últimos 30 días)
Niraj Acharya
Niraj Acharya el 24 de Oct. de 2019
Comentada: Ajay Pattassery el 1 de Nov. de 2019
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 comentario
Ajay Pattassery
Ajay Pattassery el 1 de Nov. de 2019
can you post the output of size(mnist_test_y) and size(pred)

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by