{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Plot ROC (Receiver operating characteristic)\n\nGiven a trained model, it showcase the Area under the curve of both train and test data.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from sklearn import datasets, model_selection, svm\n\nfrom dfds_ds_toolbox.analysis.plotting import plot_roc_curve\n\nX, y = datasets.make_classification(random_state=0)\nX_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, random_state=0)\nclf = svm.SVC(random_state=0, probability=True)\nclf.fit(X_train, y_train)\n\ny_pred_train = clf.predict_proba(X_train)[:, 1]\ny_pred_test = clf.predict_proba(X_test)[:, 1]\n\nfig = plot_roc_curve(y_true=y_train, y_pred=y_pred_train, label=\"Train\")\nax = fig.get_axes()[0]\nfig = plot_roc_curve(y_true=y_test, y_pred=y_pred_test, label=\"Test\", ax=ax)"
      ]
    }
  ],
  "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.10.8"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}