当前位置:网站首页>机器学习面试准备(一)KNN
机器学习面试准备(一)KNN
2022-06-30 09:48:00 【开始学AI】
目录
一、简述一下KNN算法的原理?
KNN(K-Nearest Neighbor)是一种基本的分类与回归方法,给定一个训练数据集,对于新的输入实例,在数据集中找到与该实例的最邻近的K个实例,如果这K个实例的多数属于某个类,就把该输入实例归为这一类。
KNN不具备显示的学习过程,实际上是利用训练数据集对特征空间进行划分,并作为其分类的模型。

二、KNN算法的三要素
距离度量:一般采用LP距离。(P=1,曼哈顿距离;P=2,欧氏距离;P=∞,切比雪夫距离)
K值选择:一般选取一个比较小的数,通常选择交叉验证的方法来选取最佳的K值。
分类决策规则:一般采用多数表决规则
三、如何理解K值的选择
如果K值选择较小,就相当于用较小领域中的训练实例去预测,“学习”的近似误差会减小,但估计误差会增大,如果邻近的点是噪声,预测就会出错。另外,K值的减小意味着整体模型变得复杂,容易发生过拟合。
如果K值选择较大,就相当于用较大领域中的训练实例去预测,学习的估计误差会减小,近似误差会增大,此时与输入实例较远(不相似的)实例也会对预测起作用,使预测发生错误,K值增大意味着整体的模型变得简单。
在应用中,一般选取一个比较小的数,通常选择交叉验证的方法来选取最佳的K值。
四、kd树是什么及其作用?
KNN最简单的实现方法是线性扫描,因为要对每个实例计算距离,所以当训练集很大,训练实例维度很高,计算会非常耗时。为了提高KNN搜索的效率,可以采用kd树来存储数据

五、KNN的优缺点

参考:
《统计学习方法》
边栏推荐
- Es common curl finishing
- GNN hands on practice (II): reproduction graph attention network gat
- “昆明城市咖啡地图”再度开启,咖啡拉近城市距离
- MySQL index, transaction and storage engine of database (2)
- The digital collection of sunanmin's lotus heart clearing was launched on the Great Wall Digital Art
- Rider does not prompt after opening unity script
- Koreano essential creates a professional style
- 从0使用keil5软件仿真调试GD32F305
- Quick completion guide for mechanical arm (V): end effector
- Memorize the text and remember the words. Read the text and remember the words. Read the article and remember the words; 40 articles with 3500 words; 71 articles broke through the words in the middle
猜你喜欢

‘Failed to fetch current robot state‘ when using the ‘plan_ kinematic_ path‘ service #868

乡村振兴公益基金启动暨古茶树非遗保护公益行发布

郭琳加冕 2022第三季完美大师 全球人气季军

MySQL advanced SQL statement of database (2)

Nlopt -- Nonlinear Optimization -- principle introduction and application method
[email protected]體感機械臂"/>技能梳理[email protected]體感機械臂

mysql数据库基础:存储过程和函数

Dyson design award, changing the world with sustainable design

GeoffreyHinton:我的五十年深度学习生涯与研究心法

Getting started with X86 - take over bare metal control
随机推荐
ModuleNotFoundError: No module named ‘_ swigfaiss‘
Robot system dynamics - inertia parameters
WGet -- 404 not found due to spaces in URL
“昆明城市咖啡地图”再度开启,咖啡拉近城市距离
JS obtient la chaîne spécifiée spécifiant la position du caractère & sous - chaîne spécifiant la plage de position du caractère 【 détails simples 】
MySQL index, transaction and storage engine of database (1)
最新SCI影响因子公布:国产期刊最高破46分!网友:算是把IF玩明白了
著名画家史国良《丰收时节》数字藏品上线长城数艺
《锦绣中华》中老年公益文旅游-走进佛山敬老院
ArcGIS Pro脚本工具(6)——修复CAD图层数据源
L'activité "Kunming City coffee map" a rouvert
R语言plotly可视化:使用plotly可视化多分类模型的预测置信度、模型在2D网格中每个数据点预测的置信度、置信度定义为在某一点上最高分与其他类别得分之和之间的差值
MySQL advanced SQL statement of database (1)
GD32 RT-Thread RTC驱动函数
Detailed explanation of commissioning methods and techniques
train_ de.py: error: argument --save_ steps: invalid int value: ‘$[$[889580/128/4]*10/2]‘
1033 To Fill or Not to Fill
unable to convert expression into double array
How does the diode work?
"Hackers and painters" -- why not be stupid