How to use KNN to classify data in MATLAB

2 views (last 30 days)
khusnul azima
khusnul azima on 28 Jul 2018
Commented: Image Analyst on 1 Aug 2018
I'm having trouble understanding how the K-NN classification works in MATLAB. 'Here's the problem, I have a large dataset 30 out of 90 subjects.
form a dataset like this:
359.872,317.948, Under-ripe
316.988,257.132, ripe
346.748,30.782, Over-ripe
I once tried and the result: Error using load Unknown text on line number 1 of ASCII file aa.txt
In short, I want to - divide the data into 3 groups - "train" KNN and want to know validation.
I hope you can help me, thank you in advance
  3 Comments
khusnul azima
khusnul azima on 1 Aug 2018
i have tried some load function to import data but data will not appear in the form of matrices and strings.
an example of a tested load
1.fileID = fopen('tes.txt');
2.A=load('tes.txt')
3.dlmread
My file consist in columns like this :
value      value     string
359.87  317.948   Under-ripe
Image Analyst
Image Analyst on 1 Aug 2018
Unfortunately you forgot to attach 'tes.txt'. I'll check back later.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 28 Jul 2018
See attached demo.
  1 Comment
khusnul azima
khusnul azima on 1 Aug 2018
how to enter data/read data in the form of matrix and string in one execution.

Sign in to comment.

Categories

Find more on Statistics and Machine Learning Toolbox 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!