import numpy as np from math import Counter from collections import Counter #定义了K, X_train, y_train作为训练集,之后x是我们要预测,返回对应的x的y的值 def kNN_classify(k, X_train, y_train, x): assert 1 <= k <= X_train.shape[0], "k must be valid" assert X_train.shape[0] == y_train.shape[0],\ "the size of X_train must equal to the size of y_train"
scikit-learn的机器学习算法封装
最新推荐文章于 2023-07-15 17:12:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)