KNN算法 K – 若干个 N – Nearest,最近 N – Neighbors, 邻居 1.分类 对于一个未知类别的样本,在其周围寻找距离最近的K个已知样本,根据与距离成反比的加权投票,决定未知样本的类别。 # -*- coding: utf-8 -*- from __future__ import unicode_literals import numpy as np import sklearn.neighbors as sn import matplotlib.pyplot as mp train_x, train_y = [], [] with open('../../data