mirror of
https://github.com/apachecn/ailearning.git
synced 2026-05-07 22:24:18 +08:00
Merge branch 'master' of https://github.com/apachecn/MachineLearning
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -87,3 +87,4 @@ ENV/
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
.vscode
|
||||
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"python.linting.pylintEnabled": false
|
||||
}
|
||||
9
.vscode/tasks.json
vendored
9
.vscode/tasks.json
vendored
@@ -1,9 +0,0 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "0.1.0",
|
||||
"command": "/usr/bin/python",
|
||||
"isShellCommand": true,
|
||||
"args": ["${file}"],
|
||||
"showOutput": "always"
|
||||
}
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
* 1) 机器学习基础
|
||||
* [机器学习基础](./docs/1.机器学习基础.md)
|
||||
* 2) k-紧邻算法
|
||||
* 2) k-近邻算法
|
||||
* [k-近邻算法](./docs/2.k-近邻算法.md)
|
||||
* 3) 决策树
|
||||
* 4) 基于概率论的分类方法:朴素贝叶斯
|
||||
* 5) Logistic回归
|
||||
|
||||
21
docs/2.k-近邻算法.md
Normal file
21
docs/2.k-近邻算法.md
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
# 2) k-近邻算法
|
||||
|
||||
* k-近邻算法的特点
|
||||
* 优点:精度高、对异常值不敏感、无数据输入假定
|
||||
* 缺点:计算复杂度高、空间复杂度高
|
||||
* 适用数据范围:数值型和标称型
|
||||
* 工作原理
|
||||
* 已知样本数据集的每一个数据的特征和所属分类,将新数据的特征与样本数据进行比较,找到最相似(最近邻)的k(通常k <= 20)个数据。选择k个数据中出现次数最多的分类,作为新数据的分类。
|
||||
* k-近邻算法的一般流程
|
||||
* 收集数据:任何方法
|
||||
* 准备数据:距离计算所需要的数值,最好是结构化的数据格式
|
||||
* 分析数据:任何方法
|
||||
* 测试数据:计算错误率
|
||||
* 使用算法:输入样本数据和结构化的输出结果,然后运行k-近邻算法判断输入数据分类属于哪个分类,最后对计算出的分类执行后续处理
|
||||
* 总结
|
||||
* k-近邻算法其实就是根据空间两个向量距离来判断类别性,关键的是引入k值,保证了一定的稳定性,很明显的缺点就是每次都要与所有样本数据进行对比。
|
||||
* 文中处理约会数据时,归一化的方法是对于消除影响很十分重要的
|
||||
* 阅读本章之前建议阅读一下numpy的文档
|
||||
* [numpy英文文档](https://docs.scipy.org/doc/numpy-dev/user/quickstart.html)
|
||||
* [numpy中文文档](http://old.sebug.net/paper/books/scipydoc/numpy_intro.html)
|
||||
Reference in New Issue
Block a user