'Fit LinearDiscriminantAnalysis model according to the given
training data and parameters.
.. versionchanged:: 0.19
*store_covariance* has been moved to main constructor.
.. versionchanged:: 0.19
*tol* has been moved to main constructor.
Parameters
X : array-like, shape (n_samples, n_features)
Training data.
y : array, shape (n_samples,)
Target values.'

def fit(self, X, y):

    (X, y) = check_X_y(X, y, ensure_min_samples=2, estimator=self)
    self.classes_ = unique_labels(y)
    if (self.priors is None):
        (_, y_t) = np.unique(y, return_inverse=True)
        self.priors_ = (np.bincount(y_t) / float(len(y)))
    else:
        self.priors_ = np.asarray(self.priors)
    if (self.priors_ < 0).any():
        raise ValueError('priors    must    be    non-negative')
    if (self.priors_.sum() != 1):
        warnings.warn('The    priors    do    not    sum    to    1.    Renormalizing', UserWarning)
        self.priors_ = (self.priors_ / self.priors_.sum())
    if (self.n_components is None):
        self._max_components = (len(self.classes_) - 1)
    else:
        self._max_components = min((len(self.classes_) - 1), self.n_components)
    if (self.solver == 'svd'):
        if (self.shrinkage is not None):
            raise NotImplementedError('shrinkage    not    supported')
        self._solve_svd(X, y)
    elif (self.solver == 'lsqr'):
        self._solve_lsqr(X, y, shrinkage=self.shrinkage)
    elif (self.solver == 'eigen'):
        self._solve_eigen(X, y, shrinkage=self.shrinkage)
    else:
        raise ValueError("unknown    solver    {}    (valid    solvers    are    'svd',    'lsqr',    and    'eigen').".format(self.solver))
    if (self.classes_.size == 2):
        self.coef_ = np.array((self.coef_[1, :] - self.coef_[0, :]), ndmin=2)
        self.intercept_ = np.array((self.intercept_[1] - self.intercept_[0]), ndmin=1)
    return self
