146k views
2 votes
Which of the following option is true about k-NN algorithm?

a) it can be used for classification
b) it can be used for regression
c) it can be used for both classification and regression

User Gooey
by
8.3k points

1 Answer

6 votes

Final answer:

The k-NN algorithm can be used for both classification and regression tasks. It classifies by majority vote among the k closest data points, and it predicts numeric values by averaging the values of those neighbors. Therefore, the correct answer is that the k-NN algorithm can be used for both classification and regression.

Step-by-step explanation:

The k-NN algorithm (k-nearest neighbors algorithm) is a versatile machine-learning method that can be used for both classification and regression tasks. In classification, it identifies the class of an observation by finding the most common class among its k closest examples in the data set. In regression, it predicts a numeric value based on the average of the k closest examples.

To clarify, option a) states that it can be used for classification, which is true, as k-NN can classify items by majority vote of their neighbors. Option b) claims that it can be used for regression, which is also true, as k-NN can predict a continuous value by averaging the values of the neighbors. Consequently, option c) which can be used for both classification and regression is the correct answer because k-NN is adaptive to both types of problems, depending on the nature of the output variable (categorical for classification, continuous for regression).

User Will Hua
by
8.2k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.