帮忙看看怎么修改这个python程序错误

g
gooog
楼主 (北美华人网)
下面是一个样本程序。https://scikit-learn.org/stable/modules/model_evaluation.html#scoring-parameter 一模一样的程序,但是运行总是提示错。大侠帮忙改改。多谢!
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)
d
duduxixi66
chatgpt
w
wfmlover
哪个大侠能够不看error message就告诉你程序哪里出错了
s
springbee
看看你的sklearn package version是不是跟原版一样的。不同的version,function的用法也会不同。
g
gooog
看看你的sklearn package version是不是跟原版一样的。不同的version,function的用法也会不同。
springbee 发表于 2023-03-29 12:49

你能运行无误吗?
拷贝粘贴,就能立即运行。这是段标准的skikit-learn提供的demo codes。
怎么在我这运行不了。
chatgpt根本无能。
5
50cents
哈哈哈哈哈哈,这个帖子就是chatgpt发的
g
gooog
哪个大侠能够不看error message就告诉你程序哪里出错了
wfmlover 发表于 2023-03-29 12:47

demo codes。copy and paste into python ide就能运行的。奇怪。就是不能正确。
C
Cumberbitch
怎么又是这个id goog和microsat这两个id是只负责发一些弱智问题让华人网帮忙完成自己的project来的吗 那你评tenure是不是应该评给huaren啊
g
gooog
看看你的sklearn package version是不是跟原版一样的。不同的version,function的用法也会不同。
springbee 发表于 2023-03-29 12:49

多谢!