看看你的sklearn package version是不是跟原版一样的。不同的version,function的用法也会不同。 springbee 发表于 2023-03-29 12:49
哪个大侠能够不看error message就告诉你程序哪里出错了 wfmlover 发表于 2023-03-29 12:47
from sklearn.model_selection import cross_validate from sklearn.metrics import confusion_matrix from sklearn.svm import LinearSVC
# A sample toy binary classification dataset X, y = datasets.make_classification(n_classes=2, random_state=0) svm = LinearSVC(random_state=0) def confusion_matrix_scorer(clf, X, y): y_pred = clf.predict(X) cm = confusion_matrix(y, y_pred) return {'tn': cm[0, 0], 'fp': cm[0, 1],'fn': cm[1, 0], 'tp': cm[1, 1]}
cv_results = cross_validate(svm, X, y, cv=5, scoring=confusion_matrix_scorer)
你能运行无误吗?
拷贝粘贴,就能立即运行。这是段标准的skikit-learn提供的demo codes。
怎么在我这运行不了。
chatgpt根本无能。
demo codes。copy and paste into python ide就能运行的。奇怪。就是不能正确。
多谢!