.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "glr_examples/view/plot_roc.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_glr_examples_view_plot_roc.py: ================================================= Plot Receiving Operating Characteristic (ROC) ================================================= visualizes the ROC classifier(s) performance. .. GENERATED FROM PYTHON SOURCE LINES 8-11 .. code-block:: Python # Author: L.Kouadio # Licence: BSD-3-clause .. GENERATED FROM PYTHON SOURCE LINES 12-16 it can plot multiple classifiers at once. If multiple classifiers are given, each classifier must be a tuple of ``( , classifier>, )``. Refer to :meth:`~watex.view.mlplot.EvalPlot.plotROC` .. GENERATED FROM PYTHON SOURCE LINES 16-37 .. code-block:: Python # (1) Plot ROC for single classifier # note that plot can be customize from watex.exlib.sklearn import SGDClassifier, RandomForestClassifier from watex.datasets.dload import load_bagoue from watex.utils import cattarget from watex.view.mlplot import EvalPlot X , y = load_bagoue(as_frame =True ) sgd_clf = SGDClassifier(random_state= 42) # our estimator b= EvalPlot(scale = True , encode_labels=True) b.lc='b' b.lw=7 b.font_size =7. b.fit_transform(X, y) # binarize the label b.y ybin = cattarget(b.y, labels= 2 ) # can also use labels =[0, 1] b.y = ybin # plot ROC b.plotROC(sgd_clf , label =1) # class=1 .. image-sg:: /glr_examples/view/images/sphx_glr_plot_roc_001.png :alt: plot roc :srcset: /glr_examples/view/images/sphx_glr_plot_roc_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none EvalPlot(tname= None, objective= None, scale= True, ... , sns_height= 4.0, sns_aspect= 0.7, verbose= 0) .. GENERATED FROM PYTHON SOURCE LINES 38-40 (2)-> Plot ROC for multiple classifiers examples of RandomForest and SDG .. GENERATED FROM PYTHON SOURCE LINES 40-53 .. code-block:: Python b= EvalPlot(scale = True , encode_labels=True, lw =3., lc=(.9, 0, .8), font_size=7 ) sgd_clf = SGDClassifier(random_state= 42) forest_clf =RandomForestClassifier(random_state=42) b.fit_transform(X, y) # binarize the label b.y ybin = cattarget(b.y, labels= 2 ) # can also use labels =[0, 1] b.y = ybin clfs =[('sgd', sgd_clf, "decision_function" ), ('forest', forest_clf, "predict_proba")] b.plotROC (clfs =clfs , label =1 ) .. image-sg:: /glr_examples/view/images/sphx_glr_plot_roc_002.png :alt: plot roc :srcset: /glr_examples/view/images/sphx_glr_plot_roc_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none EvalPlot(tname= None, objective= None, scale= True, ... , sns_height= 4.0, sns_aspect= 0.7, verbose= 0) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.222 seconds) .. _sphx_glr_download_glr_examples_view_plot_roc.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/watex/watex/0.3.X?urlpath=lab/tree/notebooks/glr_examples/view/plot_roc.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_roc.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_roc.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_