prtClassKnn K-nearest neighbors classifier
CLASSIFIER = prtClassKnn returns a K-nearest neighbors classifier
CLASSIFIER = prtClassKnn(PROPERTY1, VALUE1, ...) constructs a
prtClassKnn object CLASSIFIER with properties as specified by
PROPERTY/VALUE pairs.
A prtClassKnn object inherits all properties from the abstract class
prtClass. In addition is has the following properties:
k - The number of neigbors to be considered
distanceFunction - The function to be used to compute the
distance from samples to cluster centers.
It must be a function handle of the form:
@(x1,x2)distFun(x1,x2). Most prtDistance*
functions will work.
For information on the K-nearest neighbors classifier algorithm, please
refer to the following URL:
http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm
A prtClassKnn object inherits the TRAIN, RUN, CROSSVALIDATE and
KFOLDS methods from prtAction. It also inherits the PLOT method
from prtClass.
Example:
TestDataSet = prtDataGenUnimodal; % Create some test and
TrainingDataSet = prtDataGenUnimodal; % training data
classifier = prtClassKnn; % Create a classifier
classifier = classifier.train(TrainingDataSet); % Train
classified = run(classifier, TestDataSet); % Test
classifier.plot;