knn最近邻算法
目录: (Table of Contents:)
- What is KNN? 什么是KNN?
- Working of KNN algorithm KNN算法的工作
- What happens when K changes? 当K变化时会发生什么?
- How to select appropriate K? 如何选择合适的K?
- Limitation of KNN KNN的局限性
- Real-world application of KNN KNN的实际应用
- Conclusion 结论
1.什么是KNN? (1. What is KNN?)
K nearest neighbors (KNN) is a supervised machine learning algorithm. A supervised machine learning algorithm’s goal is to learn a function such that f(X) = Y where X is the input, and Y is the output. KNN can be used both for classification as well as regression. In this article, we will only talk about classification. Although for regression, there is just a minute change.
K最近邻居(KNN)是一种受监督的机器学习算法。 监督式机器学习算法的目标是学习一个函数,使得f(X)= Y,其中X是输入,Y是输出。 KNN可用于分类和回归。 在本文中,我们仅讨论分类。 尽管要进行回归,但只有一分钟的变化。
The properties of KNN is that it is a lazy learning algorithm and a non-parametric method.
KNN的特性是它是一种惰性学习算法和非参数方法。
Lazy learning means the algorithm takes almost zero time to learn because it only stores the data of the training part (no learning of a function). The stored data will then be used for the evaluation of a new query point.
惰性学习意味着该算法几乎只需花费零时间进行学习,因为它仅存储训练部分的数据(不学习功能)。 然后,存储的数据将用于评估新的查询点。
The non-parametric method refers to a method that does not assume any distribution. Therefore, KNN does not have to find any parameter for the distribution. While in the parametric method, the model finds new parameters, which in turn will be used for the prediction purpose. The only hyperparameter (provided by the user to the model) KNN has is K, which is the number of points that needs to be considered for comparison purpose.
非参数方法是指不假定任何分布的方法。 因此,KNN不必为分布找到任何参数。 在参数化方法中,模型会找到新参数,这些参数又将用于预测目的。 KNN唯一的超参数(由用户提供给模型)是K,这是比较目的需要考虑的点数。
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/329cbf7a4ed297657bcc9a276e037663.png)