[MRG] fix bad naming in make scorer example
@@ -174,24 +174,23 @@ Here is an example of building custom scorers, and of using the
``greater_is_better`` parameter::
>>> import numpy as np
- >>> def my_custom_loss_func(ground_truth, predictions):
- ... diff = np.abs(ground_truth - predictions).max()
+ >>> def my_custom_loss_func(y_true, y_pred):
+ ... diff = np.abs(y_true - y_pred).max()
... return np.log(1 + diff)
...
- >>> # loss_func will negate the return value of my_custom_loss_func,
- >>> # which will be np.log(2), 0.693, given the values for ground_truth
- >>> # and predictions defined below.
- >>> loss = make_scorer(my_custom_loss_func, greater_is_better=False)
- >>> score = make_scorer(my_custom_loss_func, greater_is_better=True)
- >>> ground_truth = [[1], [1]]
- >>> predictions = [0, 1]
+ >>> # score will negate the return value of my_custom_loss_func,
+ >>> # which will be np.log(2), 0.693, given the values for X
+ >>> # and y defined below.
+ >>> score = make_scorer(my_custom_loss_func, greater_is_better=False)
+ >>> X = [[1], [1]]
+ >>> y = [0, 1]
>>> from sklearn.dummy import DummyClassifier
>>> clf = DummyClassifier(strategy='most_frequent', random_state=0)
- >>> clf = clf.fit(ground_truth, predictions)
- >>> loss(clf,ground_truth, predictions) # doctest: +ELLIPSIS
- -0.69...
- >>> score(clf,ground_truth, predictions) # doctest: +ELLIPSIS
+ >>> clf = clf.fit(X, y)
+ >>> my_custom_loss_func(clf.predict(X), y) # doctest: +ELLIPSIS
0.69...
+ >>> score(clf, X, y) # doctest: +ELLIPSIS
+ -0.69...
.. _diy_scoring:
