You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `needs_proba` and `needs_threshold` arguments for `make_scorer()` are deprecated in favor of `response_method`.
- `LinearSVC` and `LinearSVR` now need to have `dual` explicitly set to "auto".
- `AdaBoostClassifier` now needs to have algorithm` set to "SAMME".
- Update custom metrics documentation.
- Update tests and test data.
First, let's look at how to write valid custom metric functions. A valid custom metric function
14
14
must take two array-like positional arguments: the first being the true labels or scores, and the
15
-
second being the predicted labels or scores. This function can also take three optional keyword arguments:
15
+
second being the predicted labels or scores. This function can also take two optional keyword arguments:
16
16
17
17
1. ``greater_is_better``: a boolean keyword argument that indicates whether a higher value of the metric indicates better performance (``True``) or vice versa (``False``). The default value is ``True``.
18
-
2. ``needs_proba``: a boolean keyword argument that indicates whether the metric function requires probability estimates. The default value is ``False``.
19
-
3. ``needs_threshold``: a boolean keyword argument that indicates whether the metric function takes a continuous decision certainty. The default value is ``False``.
18
+
19
+
2. ``response_method`` : a string keyword argument that specifies the response method to use to get predictions from an estimator. Possible values are:
20
+
21
+
- ``"predict"`` : uses estimator's `predict() <https://scikit-learn.org/stable/glossary.html#term-predict>`__ method to get class labels
22
+
- ``"predict_proba"`` : uses estimator's `predict_proba() <https://scikit-learn.org/stable/glossary.html#term-predict_proba>`__ method to get class probabilities
23
+
- ``"decision_function"`` : uses estimator's `decision_function() <https://scikit-learn.org/stable/glossary.html#term-decision_function>`__ method to get continuous decision function values
24
+
- If the value is a list or tuple of the above strings, it indicates that the scorer should use the first method in the list which is implemented by the estimator.
25
+
- If the value is ``None``, it is the same as ``"predict"``.
26
+
27
+
The default value for ``response_method`` is ``None``.
20
28
21
29
Note that these keyword arguments are identical to the keyword arguments for the `sklearn.metrics.make_scorer() <https://scikit-learn.org/stable/modules/generated/sklearn.metrics.make_scorer.html#sklearn.metrics.make_scorer>`_ function and serve the same purpose.
22
30
23
-
In short, custom metric functions take two required positional arguments (order matters) and three optional keyword arguments. Here's a simple example of a custom metric function: F\ :sub:`β` with β=0.75 defined in a file called ``custom.py``.
31
+
.. important::
32
+
33
+
Previous versions of SKLL offered the ``needs_proba`` and ``needs_threshold`` keyword arguments for custom metrics but these are now deprecated in scikit-learn and replaced by the ``response_method`` keyword argument. To replicate the behavior of ``needs_proba=True``, use ``response_method="predict_proba"`` instead and to replicate ``needs_threshold=True``, use ``response_method=("decision_function", "predict_proba")`` instead.
34
+
35
+
In short, custom metric functions take two required positional arguments (order matters) and two optional keyword arguments. Here's a simple example of a custom metric function: F\ :sub:`β` with β=0.75 defined in a file called ``custom.py``.
24
36
25
37
.. code-block:: python
26
38
:caption: custom.py
@@ -30,7 +42,6 @@ In short, custom metric functions take two required positional arguments (order
30
42
deff075(y_true, y_pred):
31
43
return fbeta_score(y_true, y_pred, beta=0.75)
32
44
33
-
34
45
Obviously, you may write much more complex functions that aren't directly
35
46
available in scikit-learn. Once you have written your metric function, the next
0 commit comments