Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

classification experiments with the k-Nearest Neighbor algorithm.

Asked by Husky on 5 Feb 2013

Hi everyone

It's my first effort for KNN classification and am using wine data sample from UCI website. i was wondering what distance measures I can use in this case and how to get the computation time required to compute the distance from a sample to each other sample.

I want to determine its k nearest neighbors for each labeled sample, if the label of the sample is more common than any other label for the k nearest neighbors, then count the classification as correct. Otherwise, count the classification as incorrect.

I'd appreciate any input


data set info: attributes :
      1) Alcohol
	2) Malic acid
	3) Ash
	4) Alcalinity of ash  
and ... 13)xxx

it categorizes wines into 3 classes

one example would be:



Walter Roberson on 5 Feb 2013

Measuring computation time is difficult to do right, especially if what you are trying to do is predict how efficient different methods would be with larger datasets.

Husky on 5 Feb 2013

Thanks walter, this dataset is small, only 178 lines each having 13 attributes



No products are associated with this question.

1 Answer

Answer by Walter Roberson on 5 Feb 2013

For timing, see the File Exchange Contribution timeit

1 Comment

Husky on 5 Feb 2013

Thanks but how exactly should I use this function in KNN code?

Walter Roberson

Contact us