.. _example_decomposition_plot_sparse_coding.py: =========================================== Sparse coding with a precomputed dictionary =========================================== Transform a signal as a sparse combination of Ricker wavelets. This example visually compares different sparse coding methods using the :class:`sklearn.decomposition.SparseCoder` estimator. The Ricker (also known as Mexican hat or the second derivative of a Gaussian) is not a particularly good kernel to represent piecewise constant signals like this one. It can therefore be seen how much adding different widths of atoms matters and it therefore motivates learning the dictionary to best fit your type of signals. The richer dictionary on the right is not larger in size, heavier subsampling is performed in order to stay on the same order of magnitude. .. image:: images/plot_sparse_coding_001.png :align: center **Python source code:** :download:`plot_sparse_coding.py ` .. literalinclude:: plot_sparse_coding.py :lines: 17- **Total running time of the example:** 1.04 seconds ( 0 minutes 1.04 seconds)