'Fit the random classifier.
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.'

def fit(self, X, y, sample_weight=None):

    X = check_array(X, accept_sparse=['csr', 'csc', 'coo'], force_all_finite=False)
    if (self.strategy not in ('most_frequent', 'stratified', 'uniform', 'constant', 'prior')):
        raise ValueError('Unknown    strategy    type.')
    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.atleast_1d(y)
    self.output_2d_ = (y.ndim == 2)
    if (y.ndim == 1):
        y = np.reshape(y, ((-1), 1))
    self.n_outputs_ = y.shape[1]
    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') and any(((constant[k] not in self.classes_[k]) for k in range(self.n_outputs_)))):
        raise ValueError('The    constant    target    value    must    be    present    in    training    data')
    if ((self.n_outputs_ == 1) and (not self.output_2d_)):
        self.n_classes_ = self.n_classes_[0]
        self.classes_ = self.classes_[0]
        self.class_prior_ = self.class_prior_[0]
    return self
