code: def selection_rate(
      y_true, y_pred, *, pos_label: Any = 1, sample_weight=None
  ) -> float:
      """Calculate the fraction of predicted labels matching the 'good' outcome.
  
      The argument `pos_label` specifies the 'good' outcome. For consistency with
      other metric functions, the ``y_true`` argument is required, but ignored.
  
      Read more in the :ref:`User Guide <custom_fairness_metrics>`.
  
      Parameters
      ----------
      y_true : array_like
          The true labels (ignored)
  
      y_pred : array_like
          The predicted labels
  
      pos_label : Scalar
          The label to treat as the 'good' outcome
  
      sample_weight : array_like
          Optional array of sample weights
      """
      selected = _convert_to_ndarray_and_squeeze(y_pred) == pos_label
      if len(selected) == 0:
          raise ValueError(_EMPTY_INPUT_PREDICTIONS_ERROR_MESSAGE)
  
      s_w = np.ones(len(selected))
      if sample_weight is not None:
          s_w = np.squeeze(np.asarray(sample_weight))
  
      return np.dot(selected, s_w) / s_w.sum()
  
file_path: fairlearn/fairlearn/metrics/_base_metrics.py
imports: import numpy
  import sklearn.metrics
  from typing import Any
  from ._metric_frame import check_consistent_length
  from fairlearn.utils._input_manipulations import _convert_to_ndarray_and_squeeze
label_desc: Use image node_id 8 for calling a global function with example usage: selection_rate(y_true, y_pred) and returns: unknown