为什么我们在交叉评分前使用“”(负号)

2024-05-20 16:06:13 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么我们使用“-cross\u val\u score”而不是cross\u val\u score

cv_mae = -cross_val_score(lm,
                         x_train,y_train,
                         cv=10,
                         scoring='neg_mean_absolute_error')

Tags: trainerrorvalmeancvlmscorescoring
1条回答
网友
1楼 · 发布于 2024-05-20 16:06:13

这是由于scikit-learn中的一个约定:

All scorer objects follow the convention that higher return values are better than lower return values. Thus metrics which measure the distance between the model and the data, like metrics.mean_squared_error, are available as neg_mean_squared_error which return the negated value of the metric.

(引自here

由于您的cross_val_score返回负的MAE(请参见您将scoring='neg_mean_absolute_error'作为参数传递),因此您需要负号来获得实际的MAE

相关问题 更多 >