.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/decomposition/plot_beta_divergence.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_decomposition_plot_beta_divergence.py: ============================== Beta-divergence loss functions ============================== A plot that compares the various Beta-divergence loss functions supported by the Multiplicative-Update ('mu') solver in :class:`~sklearn.decomposition.NMF`. .. GENERATED FROM PYTHON SOURCE LINES 9-30 .. image:: /auto_examples/decomposition/images/sphx_glr_plot_beta_divergence_001.png :alt: beta-divergence(1, x) :class: sphx-glr-single-img .. code-block:: default import numpy as np import matplotlib.pyplot as plt from sklearn.decomposition._nmf import _beta_divergence print(__doc__) x = np.linspace(0.001, 4, 1000) y = np.zeros(x.shape) colors = 'mbgyr' for j, beta in enumerate((0., 0.5, 1., 1.5, 2.)): for i, xi in enumerate(x): y[i] = _beta_divergence(1, xi, 1, beta) name = "beta = %1.1f" % beta plt.plot(x, y, label=name, color=colors[j]) plt.xlabel("x") plt.title("beta-divergence(1, x)") plt.legend(loc=0) plt.axis([0, 4, 0, 3]) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.294 seconds) .. _sphx_glr_download_auto_examples_decomposition_plot_beta_divergence.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/scikit-learn/scikit-learn/0.24.X?urlpath=lab/tree/notebooks/auto_examples/decomposition/plot_beta_divergence.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_beta_divergence.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_beta_divergence.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_