generated from LufsX/Experiment-kNN
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ name = "李燕如"
|
||||
|
||||
|
||||
# 这里写自己的代码实现
|
||||
def classify(input_vector, dataSet, labels, k=3):
|
||||
def classify(input_vector, dataSet, labels, k=1):
|
||||
# 计算输入向量与数据集中每个样本的欧氏距离
|
||||
distances = np.sqrt(((dataSet - input_vector) ** 2).sum(axis=1))
|
||||
# 获取距离最近的k个样本的索引
|
||||
|
||||
Reference in New Issue
Block a user