Bonjour,
je suis débutante en matlab et j'ai essayé d'utiliser K knearest neighbors pour la classification mais un message d'erreur apparait
je n'ai pas compris l'erreur pour corriger le code, j'ai besoin de votre aide et mercii d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % **************K-Nearest Neighbors*************************** %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tic; k = 3; train_data=load ('train_data.mat'); test_data=load ('test_data.mat'); train_label=load('train_label.mat'); test_label=load ('test_label.mat'); % Test KNN with test data predicted_label = knnPredict(k, train_data, train_label, test_data); fprintf('\nTesting Set Accuracy: %f\n', ... mean(double(predicted_label == test_label)) * 100); fprintf('\nTotal Time (sec) for KNN Classification : %f\n', toc);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 Error using grp2idx (line 117) A grouping variable must be a categorical, numeric, or logical vector, a cell vector of strings, or a 2D character array. Error in knnclassify (line 81) [gindex,groups] = grp2idx(group); Error in knnPredict (line 28) label = knnclassify(k,train_data,train_label,test_data); Error in main (line 20) predicted_label = knnPredict(k, train_data, train_label, test_data);
Partager