diff --git a/sklearn/decomposition/dict_learning.py b/sklearn/decomposition/dict_learning.py index 65ae605b6c19b..844d295ecc8de 100644 --- a/sklearn/decomposition/dict_learning.py +++ b/sklearn/decomposition/dict_learning.py @@ -717,6 +717,19 @@ def dict_learning_online(X, n_components=2, alpha=1, n_iter=100, Number of iterations run. Returned only if `return_n_iter` is set to `True`. + Examples + -------- + >>> import numpy as np + >>> from sklearn.decomposition import DictionaryLearning + >>> X = np.array([[0., 0., 1.], + ... [1., 0., 0.], + ... [2., 2., 2.], + ... [2., 5., 4.]]) + >>> dico = DictionaryLearning(n_components=2, alpha=1, random_state=1) + >>> dico.fit(X).components_ # doctest: +ELLIPSIS + array([[-0.2981..., -0.7453..., -0.5962...], + [ 0.5773..., 0.5773..., 0.5773...]]) + See also -------- dict_learning