knncPlot
Plot the results of KNNC (k-nearest-neighbor classifier) after training
Contents
Syntax
- knncPlot(DS, knncPrm, mode)
Description
knncPlot(DS, knncPrm)
- DS: data set used for training (This is only used to obtain the range of the plot.)
- knncPrm: parameters of KNNC obtain from knncTrain
- mode: a string that specifies mode of plot
- '2dPosterior': for plot of the posterior-like function
- 'decBoundary': for plot of the decision boundary
Example
This example uses the Taiji dataset for classification:
[trainSet, testSet]=prData('3classes');
knncPrm=knncTrain(trainSet);
knncPrm.k=1;
Plot 2D posterior-like function:
figure; knncPlot(trainSet, knncPrm, '2dPosterior');
Plot decision boundary:
figure; knncPlot(trainSet, knncPrm, 'decBoundary');