文章目录
- 一、现象
- 二、解决方案
一、现象
......
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
recall = recall_score(y_test, y_pred)
precision = precision_score(y_test. y_pred)
......
执行语句到**“precision = precision_score(y_test. y_pred)”**这里发现报错
‘Series’ object has no attribute ‘y_pred’
二、解决方案
定位到“precision = precision_score(y_test. y_pred)”
precision = precision_score(y_test. y_pred)
发现y_test. y_pred,之间不应该是“.”,而是“,”才对
“.”转成“,” ,即可解决
precision = precision_score(y_test, y_pred)
重新跑,跑到**“precision = precision_score(y_test, y_pred)”**,不会再报错误
解决方案:带疑问,多交流,勤动手,频思考