'Fit the model using X as training data and y as target values
Parameters
X : {array-like, sparse matrix, BallTree, KDTree}
Training data. If array or matrix, shape [n_samples, n_features],
or [n_samples, n_samples] if metric=\'precomputed\'.
y : {array-like, sparse matrix}
Target values of shape = [n_samples] or [n_samples, n_outputs]'

def fit(self, X, y):

    if (not isinstance(X, (KDTree, BallTree))):
        (X, y) = check_X_y(X, y, 'csr', multi_output=True)
    if ((y.ndim == 1) or ((y.ndim == 2) and (y.shape[1] == 1))):
        if (y.ndim != 1):
            warnings.warn('A    column-vector    y    was    passed    when    a    1d    array    was    expected.    Please    change    the    shape    of    y    to    (n_samples,    ),    for    example    using    ravel().', DataConversionWarning, stacklevel=2)
        self.outputs_2d_ = False
        y = y.reshape(((-1), 1))
    else:
        self.outputs_2d_ = True
    check_classification_targets(y)
    self.classes_ = []
    self._y = np.empty(y.shape, dtype=np.int)
    for k in range(self._y.shape[1]):
        (classes, self._y[:, k]) = np.unique(y[:, k], return_inverse=True)
        self.classes_.append(classes)
    if (not self.outputs_2d_):
        self.classes_ = self.classes_[0]
        self._y = self._y.ravel()
    return self._fit(X)
