1
votes

I need to use KNN in matlab to find the closest data in training data from A.

I have data in .mat that has this kind of information (training data):

train_data =   1 232 34 21 0.542 

               2 32 333 542 0.32

and so on.

Then i have a second information that I will gather through the application but I will only get

A = 2 343 543 43 0.23

So now my question is do i only need to do is something like this, and can i use something like this?

Does KNN need to learn something or do you only need to load test data and some present data (like A) and go through some formula or preload in another function that learns it then through a second function to give you the result.

Best regards.

1
What do the 5 numbers represent? Are they coordinates in 5D space, or how should I see them? - Rody Oldenhuis
The first number is object code (like apple is 1, orange is 2). The second three numbers are RGB, and the last one is roundness of an object. Now the A is data gathered in real time, train_data is gathered via a GUI and it contains data about the fruit. - SteveWozac

1 Answers

3
votes

So you have a training set (with labels) and some test data without labels? I think you can use the function you linked to classificationknn(). If i understand your question you want something like the example: Predict Classification Based on a KNN Classifier

http://www.mathworks.se/help/stats/classification-using-nearest-neighbors.html#btap7nm