diff --git a/function.py b/function.py index 3a546eb..aef0c4f 100644 --- a/function.py +++ b/function.py @@ -41,8 +41,8 @@ name = "董秋" # 这里写自己的代码实现 import operator -from collections import Counter -def classify0(inX, dataSet, labels, k=2): +from collections import Counter +def classify0(inX, dataSet, labels, k=1): """ KNN 分类算法。 @@ -89,6 +89,8 @@ def classify0(inX, dataSet, labels, k=2): # 返回出现次数最多的类别的标签 return classCount.most_common(1)[0][0] + + def load_data(file_path):