K Nearest Neighbor cluster analysis and prediction

3 views (last 30 days)
How can write code on matlab to apply kNN function and compute the accuracy over all folds, then average the results?
To compute accuracy, do I check the ratio of test samples whose predicted labels are the same as the ground-truth labels, out of all test samples?

Answers (1)

Image Analyst
Image Analyst on 14 Dec 2020
See my attached demo.
To determine accuracy you'd have to know the ground truth labels for your test set, as well as the prediction of them of course. Then just sum up the number of correct predictions and divide by the total number of predictions.

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!