mirror of
https://github.com/apachecn/ailearning.git
synced 2026-07-02 11:16:07 +08:00
add kNN
This commit is contained in:
18
src/python/02.kNN/kNN.py
Normal file
18
src/python/02.kNN/kNN.py
Normal file
@@ -0,0 +1,18 @@
|
||||
'''
|
||||
导入科学计算包numpy和运算符模块operator
|
||||
@author: geekidentity
|
||||
'''
|
||||
from numpy import *
|
||||
import operator
|
||||
|
||||
'''
|
||||
创建数据集和标签
|
||||
|
||||
调用方式
|
||||
import kNN
|
||||
group, labels = createDateSet()11
|
||||
'''
|
||||
def createDataSet():
|
||||
group = array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]])
|
||||
labels = ['A','A','B','B']
|
||||
return group, labels
|
||||
Reference in New Issue
Block a user