knn classifier function in matlab
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In the function knnclassify(sample,training,group,k), what is the purpose of k?
I havent completely understood the explanation of the function i think.I have tried varying it but the output is always the same.
I know this is a very silly doubt i am asking, but i am just not getting it.
0 Kommentare
Antworten (1)
Walter Roberson
am 2 Jul. 2012
k The number of nearest neighbors used in the classification. Default is 1.
and
The default behavior is to use majority rule. That is, a sample point is assigned to the class the majority of the k nearest neighbors are from. Use 'consensus' to require a consensus, as opposed to majority rule. When using the 'consensus' option, points where not all of the k nearest neighbors are from the same class are not assigned to one of the classes. Instead the output Class for these points is NaN for numerical groups or '' for string named groups.
In other words, when you did your testing, the results were the same when you varied k because the majority of neighbors happened to agree with the first nearest neighbor. This can, for example, happen if your clusters do not overlap much.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!