10BC0 DOC Consistent param type for pos_label (#26237) · scikit-learn/scikit-learn@cad262c · GitHub
[go: up one dir, main page]

Skip to content

Commit cad262c

Browse files
authored
DOC Consistent param type for pos_label (#26237)
1 parent 75d1dea commit cad262c

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

sklearn/calibration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ def calibration_curve(
928928
y_prob : array-like of shape (n_samples,)
929929
Probabilities of the positive class.
930930
931-
pos_label : int or str, default=None
931+
pos_label : int, float, bool or str, default=None
932932
The label of the positive class.
933933
934934
.. versionadded:: 1.1
@@ -1042,7 +1042,7 @@ class CalibrationDisplay(_BinaryClassifierCurveDisplayMixin):
10421042
estimator_name : str, default=None
10431043
Name of estimator. If None, the estimator name is not shown.
10441044
1045-
pos_label : str or int, default=None
1045+
pos_label : int, float, bool or str, default=None
10461046
The positive class when computing the calibration curve.
10471047
By default, `estimators.classes_[1]` is considered as the
10481048
positive class.
@@ -1208,7 +1208,7 @@ def from_estimator(
12081208
- `'quantile'`: The bins have the same number of samples and depend
12091209
on predicted probabilities.
12101210
1211-
pos_label : str or int, default=None
1211+
pos_label : int, float, bool or str, default=None
12121212
The positive class when computing the calibration curve.
12131213
By default, `estimators.classes_[1]` is considered as the
12141214
positive class.
@@ -1326,7 +1326,7 @@ def from_predictions(
13261326
- `'quantile'`: The bins have the same number of samples and depend
13271327
on predicted probabilities.
13281328
1329-
pos_label : str or int, default=None
1329+
pos_label : int, float, bool or str, default=None
13301330
The positive class when computing the calibration curve.
13311331
By default, `estimators.classes_[1]` is considered as the
13321332
positive class.

sklearn/metrics/_plot/det_curve.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DetCurveDisplay(_BinaryClassifierCurveDisplayMixin):
2626
estimator_name : str, default=None
2727
Name of estimator. If None, the estimator name is not shown.
2828
29-
pos_label : str or int, default=None
29+
pos_label : int, float, bool or str, default=None
3030
The label of the positive class.
3131
3232
Attributes
@@ -117,7 +117,7 @@ def from_estimator(
117117
to 'auto', :term:`predict_proba` is tried first and if it does not
118118
exist :term:`decision_function` is tried next.
119119
120-
pos_label : str or int, default=None
120+
pos_label : int, float, bool or str, default=None
121121
The label of the positive class. When `pos_label=None`, if `y_true`
122122
is in {-1, 1} or {0, 1}, `pos_label` is set to 1, otherwise an
123123
error will be raised.
@@ -210,7 +210,7 @@ def from_predictions(
210210
sample_weight : array-like of shape (n_samples,), default=None
211211
Sample weights.
212212
213-
pos_label : str or int, default=None
213+
pos_label : int, float, bool or str, default=None
214214
The label of the positive class. When `pos_label=None`, if `y_true`
215215
is in {-1, 1} or {0, 1}, `pos_label` is set to 1, otherwise an
216216
error will be raised.

sklearn/metrics/_plot/precision_recall_curve.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PrecisionRecallDisplay(_BinaryClassifierCurveDisplayMixin):
2828
estimator_name : str, default=None
2929
Name of estimator. If None, then the estimator name is not shown.
3030
31-
pos_label : str or int, default=None
31+
pos_label : int, float, bool or str, default=None
3232
The class considered as the positive class. If None, the class will not
3333
be shown in the legend.
3434
@@ -194,7 +194,7 @@ def from_estimator(
194194
sample_weight : array-like of shape (n_samples,), default=None
195195
Sample weights.
196196
197-
pos_label : str or int, default=None
197+
pos_label : int, float, bool or str, default=None
198198
The class considered as the positive class when computing the
199199
precision and recall metrics. By default, `estimators.classes_[1]`
200200
is considered as the positive class.
@@ -306,7 +306,7 @@ def from_predictions(
306306
sample_weight : array-like of shape (n_samples,), default=None
307307
Sample weights.
308308
309-
pos_label : str or int, default=None
309+
pos_label : int, float, bool or str, default=None
310310
The class considered as the positive class when computing the
311311
precision and recall metrics.
312312

sklearn/metrics/_plot/roc_curve.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RocCurveDisplay(_BinaryClassifierCurveDisplayMixin):
2828
estimator_name : str, default=None
2929
Name of estimator. If None, the estimator name is not shown.
3030
31-
pos_label : str or int, default=None
31+
pos_label : int, float, bool or str, default=None
3232
The class considered as the positive class when computing the roc auc
3333
metrics. By default, `estimators.classes_[1]` is considered
3434
as the positive class.
@@ -213,7 +213,7 @@ def from_estimator(
213213
:term:`predict_proba` is tried first and if it does not exist
214214
:term:`decision_function` is tried next.
215215
216-
pos_label : str or int, default=None
216+
pos_label : int, float, bool or str, default=None
217217
The class considered as the positive class when computing the roc auc
218218
metrics. By default, `estimators.classes_[1]` is considered
219219
as the positive class.
@@ -328,7 +328,7 @@ def from_predictions(
328328
on a plotted ROC curve. This is useful in order to create lighter
329329
ROC curves.
330330
331-
pos_label : str or int, default=None
331+
pos_label : int, float, bool or str, default=None
332332
The label of the positive class. When `pos_label=None`, if `y_true`
333333
is in {-1, 1} or {0, 1}, `pos_label` is set to 1, otherwise an
334334
error will be raised.

sklearn/utils/_response.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _get_response_values(
4747
preference. The method returned corresponds to the first method in
4848
the list and which is implemented by `estimator`.
4949
50-
pos_label : str or int, default=None
50+
pos_label : int, float, bool or str, default=None
5151
The class considered as the positive class when computing
5252
the metrics. By default, `estimators.classes_[1]` is
5353
considered as the positive class.
@@ -58,7 +58,7 @@ def _get_response_values(
5858
Target scores calculated from the provided response_method
5959
and `pos_label`.
6060
61-
pos_label : str, int or None
61+
pos_label : int, float, bool, str or None
6262
The class considered as the positive class when computing
6363
the metrics. Returns `None` if `estimator` is a regressor.
6464
@@ -133,24 +133,24 @@ def _get_response_values_binary(estimator, X, response_method, pos_label=None):
133133
X : {array-like, sparse matrix} of shape (n_samples, n_features)
134134
Input values.
135135
136-
response_method: {'auto', 'predict_proba', 'decision_function'}
136+
response_method : {'auto', 'predict_proba', 'decision_function'}
137137
Specifies whether to use :term:`predict_proba` or
138138
:term:`decision_function` as the target response. If set to 'auto',
139139
:term:`predict_proba` is tried first and if it does not exist
140140
:term:`decision_function` is tried next.
141141
142-
pos_label : str or int, default=None
142+
pos_label : int, float, bool or str, default=None
143143
The class considered as the positive class when computing
144144
the metrics. By default, `estimators.classes_[1]` is
145145
considered as the positive class.
146146
147147
Returns
148148
-------
149-
y_pred: ndarray of shape (n_samples,)
149+
y_pred : ndarray of shape (n_samples,)
150150
Target scores calculated from the provided response_method
151151
6854 and pos_label.
152152
153-
pos_label: str or int
153+
pos_label : int, float, bool or str
154154
The class considered as the positive class when computing
155155
the metrics.
156156
"""

sklearn/utils/validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,14 +2169,14 @@ def _check_pos_label_consistency(pos_label, y_true):
21692169
21702170
Parameters
21712171
----------
2172-
pos_label : int, str or None
2172+
pos_label : int, float, bool, str or None
21732173
The positive label.
21742174
y_true : ndarray of shape (n_samples,)
21752175
The target vector.
21762176
21772177
Returns
21782178
-------
2179-
pos_label : int
2179+
pos_label : int, float, bool or str
21802180
If `pos_label` can be inferred, it will be returned.
21812181
21822182
Raises

0 commit comments

Comments
 (0)
0