在进行机器学习案例的学习中,利用KNN最近邻算法进行模型构建时,运行到最后一行代码,提示报错信息AttributeError: 'NoneType' object has no attribute 'split'
#KNN最邻近算法 K-nearest neighbors
from sklearn.neighbors import KNeighborsClassifier
model = KNeighborsClassifier(n_neighbors = 3)
model.fit( train_X , train_y )
model.score(test_X , test_y )
解决方法:查看 scikit-learn 和 threadpoolctl 的版本。
步骤:
打开cmd,进入anaconda环境下,输入conda list,查看scikit-learn 和 threadpoolctl 的版本。
conda list
我这里原始的版本为:
scikit-learn -- 1.0.2
threadpoolctl -- 2.2.0
将版本进行升级为:
pip install scikit-learn==1.2.1
pip install threadpoolctl==3.1.0
再重启一下anaconda就好啦!