[scikit-learn] Fwd: There is a problem with using "r2" to calculate cross_val_score and GridSearchCV scores

Haylee Miller mh.nwafu at gmail.com
Sun Dec 26 22:16:20 EST 2021


I don’t know if the email was successfully sent last time. I send it again
now. I’m sorry to disturb you.

---------- Forwarded message ---------
发件人: Haylee Miller <mh.nwafu at gmail.com>
Date: 2021年12月24日周五 21:17
Subject: There is a problem with using "r2" to calculate cross_val_score
and GridSearchCV scores
To: <scikit-learn at python.org>


Dear sklearn developers:

First of all, thank you for developing this module, it is very useful.
However, recently we found a small problem in the use of cross_val_score
and GridSearchCV.
Using "scoring = ‘r2’" to calculate the cross_val_score and GridSearchCV
scores is inconsistent with the result calculated using "metrics.r2_score".
[image: 5.png]
According to the principle of k-fold cross-validation, we performed manual
3-fold cross-validation and there was a big gap between the score and the
result of cross_val_score.
Below is the code and results of our manual verification process.
[image: 1.png]
[image: 2.png]

[image: 3.png][image: 4.png]

Theoretically, the three values in results 1-3 should be similar to the
three values in cross_val_score 1 and cross_val_score 2.
However, only the first value in cross_val_score 1 and cross_val_score 2 is
close to the result 1-3 in  figures.
Why is this so, looking forward to your reply!
Finally, Merry Christmas!

Best wishes,
Ma Hui
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20211227/85bec9cc/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.png
Type: image/png
Size: 13921 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20211227/85bec9cc/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.png
Type: image/png
Size: 12312 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20211227/85bec9cc/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3.png
Type: image/png
Size: 11661 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20211227/85bec9cc/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4.png
Type: image/png
Size: 21220 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20211227/85bec9cc/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5.png
Type: image/png
Size: 31637 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20211227/85bec9cc/attachment-0009.png>


More information about the scikit-learn mailing list