0

I have a sample matrix, training matrix and a group matrix. I have used the obsolete knnclassify() function. I would like to replace it with the fitcknn() function. I'm new to matlab. How does the fitcknn() method work and what are the changes that i need to make to make my code work? Screenshot attached.enter image description here

tausun
  • 2,154
  • 2
  • 24
  • 36

1 Answers1

0

Everything is well described in the documentation, you should read it.

First train your model with your training dataset:

Mdl = fitcknn(TD,GT,'NumNeighbors',3); %TD = training dataset, Gr = ground truth

Then apply your model to your sample dataset:

Class = predict(Mdl,SD); %SD = sample dataset
obchardon
  • 10,614
  • 1
  • 17
  • 33