{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Beta-divergence loss functions\n\n\nA plot that compares the various Beta-divergence loss functions supported by\nthe Multiplicative-Update ('mu') solver in :class:`sklearn.decomposition.NMF`.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.decomposition.nmf import _beta_divergence\n\nprint(__doc__)\n\nx = np.linspace(0.001, 4, 1000)\ny = np.zeros(x.shape)\n\ncolors = 'mbgyr'\nfor j, beta in enumerate((0., 0.5, 1., 1.5, 2.)):\n    for i, xi in enumerate(x):\n        y[i] = _beta_divergence(1, xi, 1, beta)\n    name = \"beta = %1.1f\" % beta\n    plt.plot(x, y, label=name, color=colors[j])\n\nplt.xlabel(\"x\")\nplt.title(\"beta-divergence(1, x)\")\nplt.legend(loc=0)\nplt.axis([0, 4, 0, 3])\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}