Skip to content

DOC Consistent param type for pos_label #26237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sklearn/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ def calibration_curve(
y_prob : array-like of shape (n_samples,)
Probabilities of the positive class.

pos_label : int or str, default=None
pos_label : int, float, bool or str, default=None
The label of the positive class.

.. versionadded:: 1.1
Expand Down Expand Up @@ -1042,7 +1042,7 @@ class CalibrationDisplay(_BinaryClassifierCurveDisplayMixin):
estimator_name : str, default=None
Name of estimator. If None, the estimator name is not shown.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The positive class when computing the calibration curve.
By default, `estimators.classes_[1]` is considered as the
positive class.
Expand Down Expand Up @@ -1208,7 +1208,7 @@ def from_estimator(
- `'quantile'`: The bins have the same number of samples and depend
on predicted probabilities.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The positive class when computing the calibration curve.
By default, `estimators.classes_[1]` is considered as the
positive class.
Expand Down Expand Up @@ -1326,7 +1326,7 @@ def from_predictions(
- `'quantile'`: The bins have the same number of samples and depend
on predicted probabilities.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The positive class when computing the calibration curve.
By default, `estimators.classes_[1]` is considered as the
positive class.
Expand Down
6 changes: 3 additions & 3 deletions sklearn/metrics/_plot/det_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DetCurveDisplay(_BinaryClassifierCurveDisplayMixin):
estimator_name : str, default=None
Name of estimator. If None, the estimator name is not shown.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The label of the positive class.

Attributes
Expand Down Expand Up @@ -117,7 +117,7 @@ def from_estimator(
to 'auto', :term:`predict_proba` is tried first and if it does not
exist :term:`decision_function` is tried next.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The label of the positive class. When `pos_label=None`, if `y_true`
is in {-1, 1} or {0, 1}, `pos_label` is set to 1, otherwise an
error will be raised.
Expand Down Expand Up @@ -210,7 +210,7 @@ def from_predictions(
sample_weight : array-like of shape (n_samples,), default=None
Sample weights.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The label of the positive class. When `pos_label=None`, if `y_true`
is in {-1, 1} or {0, 1}, `pos_label` is set to 1, otherwise an
error will be raised.
Expand Down
6 changes: 3 additions & 3 deletions sklearn/metrics/_plot/precision_recall_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PrecisionRecallDisplay(_BinaryClassifierCurveDisplayMixin):
estimator_name : str, default=None
Name of estimator. If None, then the estimator name is not shown.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The class considered as the positive class. If None, the class will not
be shown in the legend.

Expand Down Expand Up @@ -194,7 +194,7 @@ def from_estimator(
sample_weight : array-like of shape (n_samples,), default=None
Sample weights.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The class considered as the positive class when computing the
precision and recall metrics. By default, `estimators.classes_[1]`
is considered as the positive class.
Expand Down Expand Up @@ -306,7 +306,7 @@ def from_predictions(
sample_weight : array-like of shape (n_samples,), default=None
Sample weights.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The class considered as the positive class when computing the
precision and recall metrics.

Expand Down
6 changes: 3 additions & 3 deletions sklearn/metrics/_plot/roc_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RocCurveDisplay(_BinaryClassifierCurveDisplayMixin):
estimator_name : str, default=None
Name of estimator. If None, the estimator name is not shown.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The class considered as the positive class when computing the roc auc
metrics. By default, `estimators.classes_[1]` is considered
as the positive class.
Expand Down Expand Up @@ -213,7 +213,7 @@ def from_estimator(
:term:`predict_proba` is tried first and if it does not exist
:term:`decision_function` is tried next.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The class considered as the positive class when computing the roc auc
metrics. By default, `estimators.classes_[1]` is considered
as the positive class.
Expand Down Expand Up @@ -328,7 +328,7 @@ def from_predictions(
on a plotted ROC curve. This is useful in order to create lighter
ROC curves.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The label of the positive class. When `pos_label=None`, if `y_true`
is in {-1, 1} or {0, 1}, `pos_label` is set to 1, otherwise an
error will be raised.
Expand Down
12 changes: 6 additions & 6 deletions sklearn/utils/_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _get_response_values(
preference. The method returned corresponds to the first method in
the list and which is implemented by `estimator`.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The class considered as the positive class when computing
the metrics. By default, `estimators.classes_[1]` is
considered as the positive class.
Expand All @@ -58,7 +58,7 @@ def _get_response_values(
Target scores calculated from the provided response_method
and `pos_label`.

pos_label : str, int or None
pos_label : int, float, bool, str or None
The class considered as the positive class when computing
the metrics. Returns `None` if `estimator` is a regressor.

Expand Down Expand Up @@ -133,24 +133,24 @@ def _get_response_values_binary(estimator, X, response_method, pos_label=None):
X : {array-like, sparse matrix} of shape (n_samples, n_features)
Input values.

response_method: {'auto', 'predict_proba', 'decision_function'}
response_method : {'auto', 'predict_proba', 'decision_function'}
Specifies whether to use :term:`predict_proba` or
:term:`decision_function` as the target response. If set to 'auto',
:term:`predict_proba` is tried first and if it does not exist
:term:`decision_function` is tried next.

pos_label : str or int, default=None
pos_label : int, float, bool or str, default=None
The class considered as the positive class when computing
the metrics. By default, `estimators.classes_[1]` is
considered as the positive class.

Returns
-------
y_pred: ndarray of shape (n_samples,)
y_pred : ndarray of shape (n_samples,)
Target scores calculated from the provided response_method
and pos_label.

pos_label: str or int
pos_label : int, float, bool or str
The class considered as the positive class when computing
the metrics.
"""
Expand Down
4 changes: 2 additions & 2 deletions sklearn/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2162,14 +2162,14 @@ def _check_pos_label_consistency(pos_label, y_true):

Parameters
----------
pos_label : int, str or None
pos_label : int, float, bool, str or None
The positive label.
y_true : ndarray of shape (n_samples,)
The target vector.

Returns
-------
pos_label : int
pos_label : int, float, bool or str
If `pos_label` can be inferred, it will be returned.

Raises
Expand Down