code: def discrimination_threshold(
      estimator,
      X,
      y,
      ax=None,
      n_trials=50,
      cv=0.1,
      fbeta=1.0,
      argmax="fscore",
      exclude=None,
      quantiles=QUANTILES_MEDIAN_80,
      random_state=None,
      is_fitted="auto",
      force_model=False,
      show=True,
      **kwargs,
  ):
      """Discrimination Threshold
  
      Visualizes how precision, recall, f1 score, and queue rate change as the
      discrimination threshold increases. For probabilistic, binary classifiers,
      the discrimination threshold is the probability at which you choose the
      positive class over the negative. Generally this is set to 50%, but
      adjusting the discrimination threshold will adjust sensitivity to false
      positives which is described by the inverse relationship of precision and
      recall with respect to the threshold.
  
      .. seealso:: See DiscriminationThreshold for more details.
  
      Parameters
      ----------
      estimator : estimator
          A scikit-learn estimator that should be a classifier. If the model is
          not a classifier, an exception is raised. If the internal model is not
          fitted, it is fit when the visualizer is fitted, unless otherwise specified
          by ``is_fitted``.
  
      X : ndarray or DataFrame of shape n x m
          A matrix of n instances with m features
  
      y : ndarray or Series of length n
          An array or series of target or class values. The target y must
          be a binary classification target.
  
      ax : matplotlib Axes, default: None
          The axes to plot the figure on. If not specified the current axes will be
          used (or generated if required).
  
      n_trials : integer, default: 50
          Number of times to shuffle and split the dataset to account for noise
          in the threshold metrics curves. Note if cv provides > 1 splits,
          the number of trials will be n_trials * cv.get_n_splits()
  
      cv : float or cross-validation generator, default: 0.1
          Determines the splitting strategy for each trial. Possible inputs are:
  
          - float, to specify the percent of the test split
          - object to be used as cross-validation generator
  
          This attribute is meant to give flexibility with stratified splitting
          but if a splitter is provided, it should only return one split and
          have shuffle set to True.
  
      fbeta : float, 1.0 by default
          The strength of recall versus precision in the F-score.
  
      argmax : str or None, default: 'fscore'
          Annotate the threshold maximized by the supplied metric (see exclude
          for the possible metrics to use). If None or passed to exclude,
          will not annotate the graph.
  
      exclude : str or list, optional
          Specify metrics to omit from the graph, can include:
  
          - ``"precision"``
          - ``"recall"``
          - ``"queue_rate"``
          - ``"fscore"``
  
          Excluded metrics will not be displayed in the graph, nor will they
          be available in ``thresholds_``; however, they will be computed on fit.
  
      quantiles : sequence, default: np.array([0.1, 0.5, 0.9])
          Specify the quantiles to view model variability across a number of
          trials. Must be monotonic and have three elements such that the first
          element is the lower bound, the second is the drawn curve, and the
          third is the upper bound. By default the curve is drawn at the median,
          and the bounds from the 10th percentile to the 90th percentile.
  
      random_state : int, optional
          Used to seed the random state for shuffling the data while composing
          different train and test splits. If supplied, the random state is
          incremented in a deterministic fashion for each split.
  
          Note that if a splitter is provided, it's random state will also be
          updated with this random state, even if it was previously set.
  
      is_fitted : bool or str, default="auto"
          Specify if the wrapped estimator is already fitted. If False, the estimator
          will be fit when the visualizer is fit, otherwise, the estimator will not be
          modified. If "auto" (default), a helper method will check if the estimator
          is fitted before fitting it again.
  
      force_model : bool, default: False
          Do not check to ensure that the underlying estimator is a classifier. This
          will prevent an exception when the visualizer is initialized but may result
          in unexpected or unintended behavior.
  
      show : bool, default: True
          If True, calls ``show()``, which in turn calls ``plt.show()`` however you cannot
          call ``plt.savefig`` from this signature, nor ``clear_figure``. If False, simply
          calls ``finalize()``
  
      kwargs : dict
          Keyword arguments passed to the visualizer base classes.
  
      Notes
      -----
      The term "discrimination threshold" is rare in the literature. Here, we
      use it to mean the probability at which the positive class is selected
      over the negative class in binary classification.
  
      Classification models must implement either a ``decision_function`` or
      ``predict_proba`` method in order to be used with this class. A
      ``YellowbrickTypeError`` is raised otherwise.
  
      .. seealso::
          For a thorough explanation of discrimination thresholds, see:
          `Visualizing Machine Learning Thresholds to Make Better Business
          Decisions
          <http://blog.insightdatalabs.com/visualizing-classifier-thresholds/>`_
          by Insight Data.
  
      Examples
      --------
      >>> from yellowbrick.classifier.threshold import discrimination_threshold
      >>> from sklearn.linear_model import LogisticRegression
      >>> from yellowbrick.datasets import load_occupancy
      >>> X, y = load_occupancy()
      >>> model = LogisticRegression(multi_class="auto", solver="liblinear")
      >>> discrimination_threshold(model, X, y)
  
      Returns
      -------
      viz : DiscriminationThreshold
          Returns the fitted and finalized visualizer object.
      """
      # Instantiate the visualizer
      visualizer = DiscriminationThreshold(
          estimator,
          ax=ax,
          n_trials=n_trials,
          cv=cv,
          fbeta=fbeta,
          argmax=argmax,
          exclude=exclude,
          quantiles=quantiles,
          random_state=random_state,
          is_fitted=is_fitted,
          force_model=force_model,
          **kwargs,
      )
  
      # Fit and transform the visualizer (calls draw)
      visualizer.fit(X, y)
  
      if show:
          visualizer.show()
      else:
          visualizer.finalize()
  
      # Return the visualizer
      return visualizer
  
imports: import bisect
  import numpy
  from scipy.stats import mstats
  from collections import defaultdict
  from sklearn.base import clone
  from sklearn.utils import indexable
  from sklearn.model_selection import ShuffleSplit
  from sklearn.metrics import precision_recall_curve
  from sklearn.utils.multiclass import type_of_target
  from yellowbrick.base import ModelVisualizer
  from yellowbrick.style.colors import resolve_colors
  from yellowbrick.utils import is_classifier, is_monotonic, is_probabilistic
  from yellowbrick.exceptions import YellowbrickTypeError, YellowbrickValueError
label_desc: Use image node_id 1 for calling a global function with example usage: discrimination_threshold(estimator, X, y, ax, n_trials, cv, fbeta, argmax, exclude, quantiles, random_state, is_fitted, force_model, show) and returns: visualizer