'Fit the model to the data X.
Parameters
X : array-like, shape (n_samples, n_features)
Training vector, where n_samples in the number of samples and
n_features is the number of features.
Returns
X : ndarray, shape (n_samples, n_features)
The input data, copied, centered and whitened when requested.'

def _fit(self, X):

    random_state = check_random_state(self.random_state)
    X = np.atleast_2d(as_float_array(X, copy=self.copy))
    n_samples = X.shape[0]
    self.mean_ = np.mean(X, axis=0)
    X -= self.mean_
    if (self.n_components is None):
        n_components = X.shape[1]
    else:
        n_components = self.n_components
    (U, S, V) = randomized_svd(X, n_components, n_iter=self.iterated_power, random_state=random_state)
    self.explained_variance_ = exp_var = ((S ** 2) / (n_samples - 1))
    full_var = np.var(X, ddof=1, axis=0).sum()
    self.explained_variance_ratio_ = (exp_var / full_var)
    self.singular_values_ = S
    if self.whiten:
        self.components_ = ((V / S[:, np.newaxis]) * sqrt(n_samples))
    else:
        self.components_ = V
    return X
