File "C:\Users\Lenovo\Desktop\bysj\first\sjfx\luyou.py", line 558, in
from sklearn import model_selection
from sklearn import model_selection
from sklearn import svm
lfw_Happy_travel_num = pd.DataFrame(
{'景点评分': lfw_Happy_travel['spot-comment'],
'花费': lfw_Happy_travel['cost'],
'Score': lfw_Happy_travel['Score']
})
x = lfw_Happy_travel_num.iloc[:, 0:2].values.tolist()
y = lfw_Happy_travel_num.iloc[:, -1].tolist()
x_train, x_test, y_train, y_test = model_selection.train_test_split(x, y, random_state=1, test_size=0.3)
clf = svm.SVC(C=0.1, kernel='linear', decision_function_shape='ovr')
# clf = svm.SVC(kernel='rbf', gamma=0.1, decision_function_shape='ovo', C=0.8)
clf.fit(x_train, y_train)
print("SVM-输出训练集的准确率为:", clf.score(x_train, y_train))
print("SVM-输出测试集的准确率为:", clf.score(x_test, y_test))
######self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。
model_selection,这个没有
sklearn配置对了么,检查pycharm配置。
该回答引用GPTᴼᴾᴱᴺᴬᴵ
这个错误提示是无法找到指定的模块,可能是你的开发环境中缺少了相应的模块。你可以尝试使用命令行安装相应的模块,例如在命令行中输入以下命令:
pip install -U scikit-learn
这将会安装最新版本的 scikit-learn 模块,如果你已经安装了这个模块,可以尝试重新安装或升级它。另外,你还可以尝试在 PyCharm 中重新设置你的解释器或虚拟环境,确保它们包含了你需要的模块。如果这些方法都无法解决问题,你可以尝试在 PyCharm 中重新创建一个新的项目,并使用相同的代码。