8000 DOC: complete docstring for regression score function · seckcoder/scikit-learn@9d638ec · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d638ec

Browse files
author
Fabian Pedregosa
committed
DOC: complete docstring for regression score function
1 parent 68236ab commit 9d638ec

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

sklearn/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,13 @@ class RegressorMixin(object):
273273
"""Mixin class for all regression estimators in scikit-learn"""
274274

275275
def score(self, X, y):
276-
"""Returns the coefficient of determination of the prediction
276+
"""Returns the coefficient of determination R^2 of the prediction.
277+
278+
The coefficient R^2 is defined as (1 - u/v), where u is the
279+
regression sum of squares ((y - y_pred) ** 2).sum() and v is the
280+
residual sum of squares ((y_true - y_true.mean()) ** 2).sum().
281+
Best possible score is 1.0, lower values are worse.
282+
277283
278284
Parameters
279285
----------
8000

sklearn/metrics/metrics.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,16 +624,20 @@ def r2_score(y_true, y_pred):
624624
625625
Best possible score is 1.0, lower values are worse.
626626
627-
Note: not a symmetric function.
628-
629-
return the R^2 score
630-
631627
Parameters
632628
----------
633629
y_true : array-like
634630
635631
y_pred : array-like
636632
633+
Returns
634+
-------
635+
z : float
636+
The R^2 score
637+
638+
Notes
639+
-----
640+
This is not a symmetric function.
637641
"""
638642
y_true, y_pred = check_arrays(y_true, y_pred)
639643
numerator = ((y_true - y_pred) ** 2).sum()

0 commit comments

Comments
 (0)
0