'Fit the model from data in 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
self : object
Returns the instance itself.'

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

    random_state = check_random_state(self.random_state)
    X = check_array(X)
    if (self.n_components is None):
        n_components = X.shape[1]
    else:
        n_components = self.n_components
    code_init = (self.V_init.T if (self.V_init is not None) else None)
    dict_init = (self.U_init.T if (self.U_init is not None) else None)
    (Vt, _, E, self.n_iter_) = dict_learning(X.T, n_components, self.alpha, tol=self.tol, max_iter=self.max_iter, method=self.method, n_jobs=self.n_jobs, verbose=self.verbose, random_state=random_state, code_init=code_init, dict_init=dict_init, return_n_iter=True)
    self.components_ = Vt.T
    self.error_ = E
    return self
