'Fit the model according to the given training data and parameters.
.. versionchanged:: 0.19
``store_covariances`` has been moved to main constructor as
``store_covariance``
.. versionchanged:: 0.19
``tol`` has been moved to main constructor.
Parameters
X : array-like, shape = [n_samples, n_features]
Training vector, where n_samples is the number of samples and
n_features is the number of features.
y : array, shape = [n_samples]
Target values (integers)'

def fit(self, X, y):

    (X, y) = check_X_y(X, y)
    check_classification_targets(y)
    (self.classes_, y) = np.unique(y, return_inverse=True)
    (n_samples, n_features) = X.shape
    n_classes = len(self.classes_)
    if (n_classes < 2):
        raise ValueError('y    has    less    than    2    classes')
    if (self.priors is None):
        self.priors_ = (np.bincount(y) / float(n_samples))
    else:
        self.priors_ = self.priors
    cov = None
    store_covariance = (self.store_covariance or self.store_covariances)
    if self.store_covariances:
        warnings.warn("'store_covariances'    was    renamed    to    store_covariance    in    version    0.19    and    will    be    removed    in    0.21.", DeprecationWarning)
    if store_covariance:
        cov = []
    means = []
    scalings = []
    rotations = []
    for ind in xrange(n_classes):
        Xg = X[(y == ind), :]
        meang = Xg.mean(0)
        means.append(meang)
        if (len(Xg) == 1):
            raise ValueError(('y    has    only    1    sample    in    class    %s,    covariance    is    ill    defined.' % str(self.classes_[ind])))
        Xgc = (Xg - meang)
        (U, S, Vt) = np.linalg.svd(Xgc, full_matrices=False)
        rank = np.sum((S > self.tol))
        if (rank < n_features):
            warnings.warn('Variables    are    collinear')
        S2 = ((S ** 2) / (len(Xg) - 1))
        S2 = (((1 - self.reg_param) * S2) + self.reg_param)
        if (self.store_covariance or store_covariance):
            cov.append(np.dot((S2 * Vt.T), Vt))
        scalings.append(S2)
        rotations.append(Vt.T)
    if (self.store_covariance or store_covariance):
        self.covariance_ = cov
    self.means_ = np.asarray(means)
    self.scalings_ = scalings
    self.rotations_ = rotations
    return self
