knncFuzzy

Fuzzy k-nearest neighbor classifier

Contents

Syntax

Description

testOut = knncFuzzy(testSet, trainSet, prm) returns the result of fuzzy KNN classifier, using the given training set trainSet and test set testSet.

References

  1. [1] J. M. Keller, M. R. Gray, and J. A. Givens, Jr., "A Fuzzy
  2. K-Nearest Neighbor Algorithm", IEEE Transactions on Systems,
  3. Man, and Cybernetics, Vol. 15, No. 4, pp. 580-585, 1985.

Example

[trainSet, testSet]=prData('3classes');
dsScatterPlot(trainSet);		% Plot the training set
line([0 1], [0 1], 'linestyle', ':');		% Plot boundary
line([0.5 1], [0.5 0], 'linestyle', ':');	% Plot boundary
prm.k=5;
prm.m=2;
[fuzzyOutput, crispOutput]=knncFuzzy(testSet, trainSet, prm);
dsScatterPlot(testSet);		% Overlay the test set
for i=1:3
	index=find(crispOutput==i);
	line(testSet.input(1, index), testSet.input(2, index), 'marker', 'o', 'color', getColor(i), 'linestyle', 'none');
end
title('Training set (dots) and test set (circles with color indicting the test results)');
fprintf('Recog. rate = %.2f%%\n', 100*sum(crispOutput==testSet.output)/length(testSet.output));
Unable to perform assignment because dot indexing is not supported for variables of this type.

Error in knncFuzzy_help (line 18)
prm.k=5;

See Also

classFuzzify.


Top page   Next: knncEval.m   Prev:knncLoo.m