gpt4 book ai didi

python - 为什么我们在 cross_val_score 之前使用 ' - '(负)符号

转载 作者:行者123 更新时间:2023-12-04 07:25:11 24 4
gpt4 key购买 nike

为什么我们使用' -cross_val_score ' 而不仅仅是 cross_val_score ?

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

最佳答案

这是由于 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。

关于python - 为什么我们在 cross_val_score 之前使用 ' - '(负)符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68241788/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com