You must pass class labels as vector
Show older comments

5 Comments
steve vincent
on 2 Jun 2022
Walter Roberson
on 2 Jun 2022
What is size(tlatih)? Also what class() is it?
steve vincent
on 2 Jun 2022
steve vincent
on 2 Jun 2022
steve vincent
on 2 Jun 2022
Answers (3)
Walter Roberson
on 2 Jun 2022
0 votes
The second parameter to fitcknn must be a vector (of various data types) with the one exception being that it can be a cell array of character vectors. It cannot be a numeric array with three columns.
Your clatih and tlatih contain exactly the same thing. Your clatih should be built from the _target variables.
3 Comments
steve vincent
on 2 Jun 2022
steve vincent
on 2 Jun 2022
Walter Roberson
on 2 Jun 2022
It is difficult to debug code that we cannot see.
For debugging purposes you should show us the output of
whos tlatih
steve vincent
on 3 Jun 2022
0 votes
1 Comment
Walter Roberson
on 3 Jun 2022
That appears to be a cell array of categorical, you should cell2mat to get a vector of categorical
steve vincent
on 3 Jun 2022
0 votes
Categories
Find more on Nearest Neighbors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
