class_docstr: DummyClassifier makes predictions that ignore the input features.
  
  This classifier serves as a simple baseline to compare against other more
  complex classifiers.
  
  The specific behavior of the baseline is selected with the `strategy`
  parameter.
  
  All strategies make predictions that ignore the input feature values passed
  as the `X` argument to `fit` and `predict`. The predictions, however,
  typically depend on values observed in the `y` parameter passed to `fit`.
  
  Note that the "stratified" and "uniform" strategies lead to
  non-deterministic predictions that can be rendered deterministic by setting
  the `random_state` parameter if needed. The other strategies are naturally
  deterministic and, once fit, always return the same constant prediction
  for any value of `X`.
  
  Read more in the :ref:`User Guide <dummy_estimators>`.
  
  .. versionadded:: 0.13
  
  Parameters
  ----------
  strategy : {"most_frequent", "prior", "stratified", "uniform",             "constant"}, default="prior"
      Strategy to use to generate predictions.
  
      * "most_frequent": the `predict` method always returns the most
        frequent class label in the observed `y` argument passed to `fit`.
        The `predict_proba` method returns the matching one-hot encoded
        vector.
      * "prior": the `predict` method always returns the most frequent
        class label in the observed `y` argument passed to `fit` (like
        "most_frequent"). ``predict_proba`` always returns the empirical
        class distribution of `y` also known as the empirical class prior
        distribution.
      * "stratified": the `predict_proba` method randomly samples one-hot
        vectors from a multinomial distribution parametrized by the empirical
        class prior probabilities.
        The `predict` method returns the class label which got probability
        one in the one-hot vector of `predict_proba`.
        Each sampled row of both methods is therefore independent and
        identically distributed.
      * "uniform": generates predictions uniformly at random from the list
        of unique classes observed in `y`, i.e. each class has equal
        probability.
      * "constant": always predicts a constant label that is provided by
        the user. This is useful for metrics that evaluate a non-majority
        class.
  
        .. versionchanged:: 0.24
           The default value of `strategy` has changed to "prior" in version
           0.24.
  
  random_state : int, RandomState instance or None, default=None
      Controls the randomness to generate the predictions when
      ``strategy='stratified'`` or ``strategy='uniform'``.
      Pass an int for reproducible output across multiple function calls.
      See :term:`Glossary <random_state>`.
  
  constant : int or str or array-like of shape (n_outputs,), default=None
      The explicit constant as predicted by the "constant" strategy. This
      parameter is useful only for the "constant" strategy.
  
  Attributes
  ----------
  classes_ : ndarray of shape (n_classes,) or list of such arrays
      Unique class labels observed in `y`. For multi-output classification
      problems, this attribute is a list of arrays as each output has an
      independent set of possible classes.
  
  n_classes_ : int or list of int
      Number of label for each output.
  
  class_prior_ : ndarray of shape (n_classes,) or list of such arrays
      Frequency of each class observed in `y`. For multioutput classification
      problems, this is computed independently for each output.
  
  n_outputs_ : int
      Number of outputs.
  
  sparse_output_ : bool
      True if the array returned from predict is to be in sparse CSC format.
      Is automatically set to True if the input `y` is passed in sparse
      format.
  
  See Also
  --------
  DummyRegressor : Regressor that makes predictions using simple rules.
  
  Examples
  --------
  >>> import numpy as np
  >>> from sklearn.dummy import DummyClassifier
  >>> X = np.array([-1, 1, 1, 1])
  >>> y = np.array([0, 1, 1, 1])
  >>> dummy_clf = DummyClassifier(strategy="most_frequent")
  >>> dummy_clf.fit(X, y)
  DummyClassifier(strategy='most_frequent')
  >>> dummy_clf.predict(X)
  array([1, 1, 1, 1])
  >>> dummy_clf.score(X, y)
  0.75
class_docstr_tok: ["DummyClassifier","makes","predictions","that","ignore","the","input","features",".","This","classifier","serves","as","a","simple","baseline","to","compare","against","other","more","complex","classifiers",".","The","specific","behavior","of","the","baseline","is","selected","with","the","`","strategy","`","parameter",".","All","strategies","make","predictions","that","ignore","the","input","feature","values","passed","as","the","`","X","`","argument","to","`","fit","`","and","`","predict","`",".","The","predictions",",","however",",","typically","depend","on","values","observed","in","the","`","y","`","parameter","passed","to","`","fit","`",".","Note","that","the","``","stratified","''","and","``","uniform","''","strategies","lead","to","non-deterministic","predictions","that","can","be","rendered","deterministic","by","setting","the","`","random_state","`","parameter","if","needed",".","The","other","strategies","are","naturally","deterministic","and",",","once","fit",",","always","return","the","same","constant","prediction","for","any","value","of","`","X","`",".","Read","more","in","the",":","ref",":","`","User","Guide","<","dummy_estimators",">","`",".","..","versionadded",":",":","0.13","Parameters","--","--","--","--","--","strategy",":","{","``","most_frequent","''",",","``","prior","''",",","``","stratified","''",",","``","uniform","''",",","``","constant","''","}",",","default=","''","prior","''","Strategy","to","use","to","generate","predictions",".","*","``","most_frequent","''",":","the","`","predict","`","method","always","returns","the","most","frequent","class","label","in","the","observed","`","y","`","argument","passed","to","`","fit","`",".","The","`","predict_proba","`","method","returns","the","matching","one-hot","encoded","vector",".","*","``","prior","''",":","the","`","predict","`","method","always","returns","the","most","frequent","class","label","in","the","observed","`","y","`","argument","passed","to","`","fit","`","(","like","``","most_frequent","''",")",".","``","predict_proba","``","always","returns","the","empirical","class","distribution","of","`","y","`","also","known","as","the","empirical","class","prior","distribution",".","*","``","stratified","''",":","the","`","predict_proba","`","method","randomly","samples","one-hot","vectors","from","a","multinomial","distribution","parametrized","by","the","empirical","class","prior","probabilities",".","The","`","predict","`","method","returns","the","class","label","which","got","probability","one","in","the","one-hot","vector","of","`","predict_proba","`",".","Each","sampled","row","of","both","methods","is","therefore","independent","and","identically","distributed",".","*","``","uniform","''",":","generates","predictions","uniformly","at","random","from","the","list","of","unique","classes","observed","in","`","y","`",",","i.e",".","each","class","has","equal","probability",".","*","``","constant","''",":","always","predicts","a","constant","label","that","is","provided","by","the","user",".","This","is","useful","for","metrics","that","evaluate","a","non-majority","class",".","..","versionchanged",":",":","0.24","The","default","value","of","`","strategy","`","has","changed","to","``","prior","''","in","version","0.24.","random_state",":","int",",","RandomState","instance","or","None",",","default=None","Controls","the","randomness","to","generate","the","predictions","when","``","strategy='stratified","'","``","or","``","strategy='uniform","'","``",".","Pass","an","int","for","reproducible","output","across","multiple","function","calls",".","See",":","term",":","`","Glossary","<","random_state",">","`",".","constant",":","int","or","str","or","array-like","of","shape","(","n_outputs",",",")",",","default=None","The","explicit","constant","as","predicted","by","the","``","constant","''","strategy",".","This","parameter","is","useful","only","for","the","``","constant","''","strategy",".","Attributes","--","--","--","--","--","classes_",":","ndarray","of","shape","(","n_classes",",",")","or","list","of","such","arrays","Unique","class","labels","observed","in","`","y","`",".","For","multi-output","classification","problems",",","this","attribute","is","a","list","of","arrays","as","each","output","has","an","independent","set","of","possible","classes",".","n_classes_",":","int","or","list","of","int","Number","of","label","for","each","output",".","class_prior_",":","ndarray","of","shape","(","n_classes",",",")","or","list","of","such","arrays","Frequency","of","each","class","observed","in","`","y","`",".","For","multioutput","classification","problems",",","this","is","computed","independently","for","each","output",".","n_outputs_",":","int","Number","of","outputs",".","sparse_output_",":","bool","True","if","the","array","returned","from","predict","is","to","be","in","sparse","CSC","format",".","Is","automatically","set","to","True","if","the","input","`","y","`","is","passed","in","sparse","format",".","See","Also","--","--","--","--","DummyRegressor",":","Regressor","that","makes","predictions","using","simple","rules",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","sklearn.dummy","import","DummyClassifier",">",">",">","X","=","np.array","(","[","-1",",","1",",","1",",","1","]",")",">",">",">","y","=","np.array","(","[","0",",","1",",","1",",","1","]",")",">",">",">","dummy_clf","=","DummyClassifier","(","strategy=","''","most_frequent","''",")",">",">",">","dummy_clf.fit","(","X",",","y",")","DummyClassifier","(","strategy='most_frequent","'",")",">",">",">","dummy_clf.predict","(","X",")","array","(","[","1",",","1",",","1",",","1","]",")",">",">",">","dummy_clf.score","(","X",",","y",")","0.75"]
docstr: Fit the baseline classifier.
  
  Parameters
  ----------
  X : array-like of shape (n_samples, n_features)
      Training data.
  
  y : array-like of shape (n_samples,) or (n_samples, n_outputs)
      Target values.
  
  sample_weight : array-like of shape (n_samples,), default=None
      Sample weights.
  
  Returns
  -------
  self : object
      Returns the instance itself.
docstr_tok: ["Fit","the","baseline","classifier",".","Parameters","--","--","--","--","--","X",":","array-like","of","shape","(","n_samples",",","n_features",")","Training","data",".","y",":","array-like","of","shape","(","n_samples",",",")","or","(","n_samples",",","n_outputs",")","Target","values",".","sample_weight",":","array-like","of","shape","(","n_samples",",",")",",","default=None","Sample","weights",".","Returns","--","--","--","-","self",":","object","Returns","the","instance","itself","."]
code: def fit(self, X, y, sample_weight=None):
      """Fit the baseline classifier.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          Training data.
  
      y : array-like of shape (n_samples,) or (n_samples, n_outputs)
          Target values.
  
      sample_weight : array-like of shape (n_samples,), default=None
          Sample weights.
  
      Returns
      -------
      self : object
          Returns the instance itself.
      """
      self._strategy = self.strategy
  
      if self._strategy == "uniform" and sp.issparse(y):
          y = y.toarray()
          warnings.warn(
              (
                  "A local copy of the target data has been converted "
                  "to a numpy array. Predicting on sparse target data "
                  "with the uniform strategy would not save memory "
                  "and would be slower."
              ),
              UserWarning,
          )
  
      self.sparse_output_ = sp.issparse(y)
  
      if not self.sparse_output_:
          y = np.asarray(y)
          y = np.atleast_1d(y)
  
      if y.ndim == 1:
          y = np.reshape(y, (-1, 1))
  
      self.n_outputs_ = y.shape[1]
  
      check_consistent_length(X, y)
  
      if sample_weight is not None:
          sample_weight = _check_sample_weight(sample_weight, X)
  
      if self._strategy == "constant":
          if self.constant is None:
              raise ValueError(
                  "Constant target value has to be specified "
                  "when the constant strategy is used."
              )
          else:
              constant = np.reshape(
                  np.atleast_1d(self.constant), (-1, 1)
              )
              if constant.shape[0] != self.n_outputs_:
                  raise ValueError(
                      "Constant target value should have shape (%d, 1)."
                      % self.n_outputs_
                  )
  
      (
          self.classes_,
          self.n_classes_,
          self.class_prior_,
      ) = class_distribution(y, sample_weight)
  
      if self._strategy == "constant":
          for k in range(self.n_outputs_):
              if not any(constant[k][0] == c for c in self.classes_[k]):
                  # Checking in case of constant strategy if the constant
                  # provided by the user is in y.
                  err_msg = (
                      "The constant target value must be present in "
                      "the training data. You provided constant={}. "
                      "Possible values are: {}.".format(
                          self.constant, self.classes_[k].tolist()
                      )
                  )
                  raise ValueError(err_msg)
  
      if self.n_outputs_ == 1:
          self.n_classes_ = self.n_classes_[0]
          self.classes_ = self.classes_[0]
          self.class_prior_ = self.class_prior_[0]
  
      return self
  
imports: import warnings
  from numbers import Integral, Real
  import numpy
  import scipy.sparse
  from .base import BaseEstimator, ClassifierMixin, MultiOutputMixin, RegressorMixin, _fit_context
  from .utils import check_random_state
  from .utils._param_validation import Interval, StrOptions
  from .utils.multiclass import class_distribution
  from .utils.random import _random_choice_csc
  from .utils.stats import _weighted_percentile
  from .utils.validation import _check_sample_weight, _num_samples, check_array, check_consistent_length, check_is_fitted
label_desc: Use image node_id 2 for calling the DummyClassifier obj's underlying member method code with example usage: obj.fit(X, y, sample_weight) and returns: self