W3cubDocs

/scikit-learn

sklearn.decomposition.dict_learning

sklearn.decomposition.dict_learning(X, n_components, alpha, max_iter=100, tol=1e-08, method='lars', n_jobs=1, dict_init=None, code_init=None, callback=None, verbose=False, random_state=None, return_n_iter=False) [source]

Solves a dictionary learning matrix factorization problem.

Finds the best dictionary and the corresponding sparse code for approximating the data matrix X by solving:

(U^*, V^*) = argmin 0.5 || X - U V ||_2^2 + alpha * || U ||_1
             (U,V)
            with || V_k ||_2 = 1 for all  0 <= k < n_components

where V is the dictionary and U is the sparse code.

Read more in the User Guide.

Parameters:

X: array of shape (n_samples, n_features) :

Data matrix.

n_components: int, :

Number of dictionary atoms to extract.

alpha: int, :

Sparsity controlling parameter.

max_iter: int, :

Maximum number of iterations to perform.

tol: float, :

Tolerance for the stopping condition.

method: {‘lars’, ‘cd’} :

lars: uses the least angle regression method to solve the lasso problem (linear_model.lars_path) cd: uses the coordinate descent method to compute the Lasso solution (linear_model.Lasso). Lars will be faster if the estimated components are sparse.

n_jobs: int, :

Number of parallel jobs to run, or -1 to autodetect.

dict_init: array of shape (n_components, n_features), :

Initial value for the dictionary for warm restart scenarios.

code_init: array of shape (n_samples, n_components), :

Initial value for the sparse code for warm restart scenarios.

callback: :

Callable that gets invoked every five iterations.

verbose: :

Degree of output the procedure will print.

random_state: int or RandomState :

Pseudo number generator state used for random sampling.

return_n_iter : bool

Whether or not to return the number of iterations.

Returns:

code: array of shape (n_samples, n_components) :

The sparse code factor in the matrix factorization.

dictionary: array of shape (n_components, n_features), :

The dictionary factor in the matrix factorization.

errors: array :

Vector of errors at each iteration.

n_iter : int

Number of iterations run. Returned only if return_n_iter is set to True.

© 2007–2016 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.dict_learning.html