class_docstr: DummyRegressor is a regressor that makes predictions using
  simple rules.
  
  This regressor is useful as a simple baseline to compare with other
  (real) regressors. Do not use it for real problems.
  
  Read more in the :ref:`User Guide <dummy_estimators>`.
  
  Parameters
  ----------
  strategy : str
      Strategy to use to generate predictions.
  
      * "mean": always predicts the mean of the training set
      * "median": always predicts the median of the training set
      * "quantile": always predicts a specified quantile of the training set,
        provided with the quantile parameter.
      * "constant": always predicts a constant value that is provided by
        the user.
  
  constant : int or float or array of shape = [n_outputs]
      The explicit constant as predicted by the "constant" strategy. This
      parameter is useful only for the "constant" strategy.
  
  quantile : float in [0.0, 1.0]
      The quantile to predict using the "quantile" strategy. A quantile of
      0.5 corresponds to the median, while 0.0 to the minimum and 1.0 to the
      maximum.
  
  Attributes
  ----------
  constant_ : float or array of shape [n_outputs]
      Mean or median or quantile of the training targets or constant value
      given by the user.
  
  n_outputs_ : int,
      Number of outputs.
  
  outputs_2d_ : bool,
      True if the output at fit is 2d, else false.
class_docstr_tok: ["DummyRegressor","is","a","regressor","that","makes","predictions","using","simple","rules",".","This","regressor","is","useful","as","a","simple","baseline","to","compare","with","other","(","real",")","regressors",".","Do","not","use","it","for","real","problems",".","Read","more","in","the",":","ref",":","`","User","Guide","<","dummy_estimators",">","`",".","Parameters","--","--","--","--","--","strategy",":","str","Strategy","to","use","to","generate","predictions",".","*","``","mean","''",":","always","predicts","the","mean","of","the","training","set","*","``","median","''",":","always","predicts","the","median","of","the","training","set","*","``","quantile","''",":","always","predicts","a","specified","quantile","of","the","training","set",",","provided","with","the","quantile","parameter",".","*","``","constant","''",":","always","predicts","a","constant","value","that","is","provided","by","the","user",".","constant",":","int","or","float","or","array","of","shape","=","[","n_outputs","]","The","explicit","constant","as","predicted","by","the","``","constant","''","strategy",".","This","parameter","is","useful","only","for","the","``","constant","''","strategy",".","quantile",":","float","in","[","0.0",",","1.0","]","The","quantile","to","predict","using","the","``","quantile","''","strategy",".","A","quantile","of","0.5","corresponds","to","the","median",",","while","0.0","to","the","minimum","and","1.0","to","the","maximum",".","Attributes","--","--","--","--","--","constant_",":","float","or","array","of","shape","[","n_outputs","]","Mean","or","median","or","quantile","of","the","training","targets","or","constant","value","given","by","the","user",".","n_outputs_",":","int",",","Number","of","outputs",".","outputs_2d_",":","bool",",","True","if","the","output","at","fit","is","2d",",","else","false","."]
docstr: Fit the random regressor.
  
  Parameters
  ----------
  X : {array-like, sparse matrix}, shape = [n_samples, n_features]
      Training vectors, where n_samples is the number of samples
      and n_features is the number of features.
  
  y : array-like, shape = [n_samples] or [n_samples, n_outputs]
      Target values.
  
  sample_weight : array-like of shape = [n_samples], optional
      Sample weights.
  
  Returns
  -------
  self : object
      Returns self.
docstr_tok: ["Fit","the","random","regressor",".","Parameters","--","--","--","--","--","X",":","{","array-like",",","sparse","matrix","}",",","shape","=","[","n_samples",",","n_features","]","Training","vectors",",","where","n_samples","is","the","number","of","samples","and","n_features","is","the","number","of","features",".","y",":","array-like",",","shape","=","[","n_samples","]","or","[","n_samples",",","n_outputs","]","Target","values",".","sample_weight",":","array-like","of","shape","=","[","n_samples","]",",","optional","Sample","weights",".","Returns","--","--","--","-","self",":","object","Returns","self","."]
code: def fit(self, X, y, sample_weight=None):
      """Fit the random regressor.
  
      Parameters
      ----------
      X : {array-like, sparse matrix}, shape = [n_samples, n_features]
          Training vectors, where n_samples is the number of samples
          and n_features is the number of features.
  
      y : array-like, shape = [n_samples] or [n_samples, n_outputs]
          Target values.
  
      sample_weight : array-like of shape = [n_samples], optional
          Sample weights.
  
      Returns
      -------
      self : object
          Returns self.
      """
  
      if self.strategy not in (
          "mean",
          "median",
          "quantile",
          "constant",
      ):
          raise ValueError(
              "Unknown strategy type: %s, expected "
              "'mean', 'median', 'quantile' or 'constant'"
              % self.strategy
          )
  
      y = check_array(y, ensure_2d=False)
      if len(y) == 0:
          raise ValueError("y must not be empty.")
  
      self.output_2d_ = y.ndim == 2
      if y.ndim == 1:
          y = np.reshape(y, (-1, 1))
      self.n_outputs_ = y.shape[1]
  
      check_consistent_length(X, y, sample_weight)
  
      if self.strategy == "mean":
          self.constant_ = np.average(y, axis=0, weights=sample_weight)
  
      elif self.strategy == "median":
          if sample_weight is None:
              self.constant_ = np.median(y, axis=0)
          else:
              self.constant_ = [
                  _weighted_percentile(
                      y[:, k], sample_weight, percentile=50.0
                  )
                  for k in range(self.n_outputs_)
              ]
  
      elif self.strategy == "quantile":
          if self.quantile is None or not np.isscalar(self.quantile):
              raise ValueError(
                  "Quantile must be a scalar in the range "
                  "[0.0, 1.0], but got %s." % self.quantile
              )
  
          percentile = self.quantile * 100.0
          if sample_weight is None:
              self.constant_ = np.percentile(y, axis=0, q=percentile)
          else:
              self.constant_ = [
                  _weighted_percentile(
                      y[:, k], sample_weight, percentile=percentile
                  )
                  for k in range(self.n_outputs_)
              ]
  
      elif self.strategy == "constant":
          if self.constant is None:
              raise TypeError(
                  "Constant target value has to be specified "
                  "when the constant strategy is used."
              )
  
          self.constant = check_array(
              self.constant,
              accept_sparse=["csr", "csc", "coo"],
              ensure_2d=False,
              ensure_min_samples=0,
          )
  
          if self.output_2d_ and self.constant.shape[0] != y.shape[1]:
              raise ValueError(
                  "Constant target value should have "
                  "shape (%d, 1)." % y.shape[1]
              )
  
          self.constant_ = self.constant
  
      self.constant_ = np.reshape(self.constant_, (1, -1))
      return self
  
imports: from __future__ import division
  import warnings
  import numpy
  import scipy.sparse
  from .base import BaseEstimator, ClassifierMixin, RegressorMixin
  from .utils import check_random_state
  from .utils.validation import check_array
  from .utils.validation import check_consistent_length
  from .utils.validation import check_is_fitted
  from .utils.random import random_choice_csc
  from .utils.stats import _weighted_percentile
  from .utils.multiclass import class_distribution
label_desc: Use image node_id 2 for calling the DummyRegressor obj's underlying member method code with example usage: obj.fit(X, y, sample_weight) and returns: self