# Doubt on results of k-Nearest Neighbors

Hi All,

I am running "04_NearestNeighbors" sample process (I have set k=2), the results show as below.

----------------------------------------------------

KNNClassification

2-Nearest Neighbour model for classification. The model contains 150 examples with 4 dimensions of the following classes:

Iris-setosa

Iris-versicolor

Iris-virginica

----------------------------------------------------

In-spite of setting k=2, it is not classifying category into two. Whatever number is assigned to k, the result remains same. Is there separate configuration for this algorithm?

Because as per the algorithm (http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm), it has to classify the items based on the distance.

Kindly clarify.

Thanks,

Best,

Veeranna Ronad.

I am running "04_NearestNeighbors" sample process (I have set k=2), the results show as below.

----------------------------------------------------

KNNClassification

2-Nearest Neighbour model for classification. The model contains 150 examples with 4 dimensions of the following classes:

Iris-setosa

Iris-versicolor

Iris-virginica

----------------------------------------------------

In-spite of setting k=2, it is not classifying category into two. Whatever number is assigned to k, the result remains same. Is there separate configuration for this algorithm?

Because as per the algorithm (http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm), it has to classify the items based on the distance.

Kindly clarify.

Thanks,

Best,

Veeranna Ronad.

0

## Answers

74GuruDoes the results change when the seed of a random generator is changed?

radone

12Contributor III hope "seed of a random generator" means the value of 'k'. Yes, the result is not changing.

Thanks,

Best,

Veranna Ronad.