Skip to content

Commit 6128edf

Browse files
committed
Pushing the docs to dev/ for branch: main, commit d753d4dc1a5aa73f753cb3ecc26d7ebb474dbfad
1 parent b80ce08 commit 6128edf

File tree

1,223 files changed

+4206
-4034
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,223 files changed

+4206
-4034
lines changed
Binary file not shown.

dev/_downloads/10bb40e21b74618cdeed618ff1eae595/plot_det.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# Detection error tradeoff (DET) curve\n\nIn this example, we compare receiver operating characteristic (ROC) and\ndetection error tradeoff (DET) curves for different classification algorithms\nfor the same classification task.\n\nDET curves are commonly plotted in normal deviate scale.\nTo achieve this `plot_det_curve` transforms the error rates as returned by the\n:func:`~sklearn.metrics.det_curve` and the axis scale using\n:func:`scipy.stats.norm`.\n\nThe point of this example is to demonstrate two properties of DET curves,\nnamely:\n\n1. It might be easier to visually assess the overall performance of different\n classification algorithms using DET curves over ROC curves.\n Due to the linear scale used for plotting ROC curves, different classifiers\n usually only differ in the top left corner of the graph and appear similar\n for a large part of the plot. On the other hand, because DET curves\n represent straight lines in normal deviate scale. As such, they tend to be\n distinguishable as a whole and the area of interest spans a large part of\n the plot.\n2. DET curves give the user direct feedback of the detection error tradeoff to\n aid in operating point analysis.\n The user can deduct directly from the DET-curve plot at which rate\n false-negative error rate will improve when willing to accept an increase in\n false-positive error rate (or vice-versa).\n\nThe plots in this example compare ROC curves on the left side to corresponding\nDET curves on the right.\nThere is no particular reason why these classifiers have been chosen for the\nexample plot over other classifiers available in scikit-learn.\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>- See :func:`sklearn.metrics.roc_curve` for further information about ROC\n curves.\n\n - See :func:`sklearn.metrics.det_curve` for further information about\n DET curves.\n\n - This example is loosely based on\n `sphx_glr_auto_examples_classification_plot_classifier_comparison.py`\n example.</p></div>\n"
18+
"\n# Detection error tradeoff (DET) curve\n\nIn this example, we compare receiver operating characteristic (ROC) and\ndetection error tradeoff (DET) curves for different classification algorithms\nfor the same classification task.\n\nDET curves are commonly plotted in normal deviate scale.\nTo achieve this the DET display transforms the error rates as returned by the\n:func:`~sklearn.metrics.det_curve` and the axis scale using\n:func:`scipy.stats.norm`.\n\nThe point of this example is to demonstrate two properties of DET curves,\nnamely:\n\n1. It might be easier to visually assess the overall performance of different\n classification algorithms using DET curves over ROC curves.\n Due to the linear scale used for plotting ROC curves, different classifiers\n usually only differ in the top left corner of the graph and appear similar\n for a large part of the plot. On the other hand, because DET curves\n represent straight lines in normal deviate scale. As such, they tend to be\n distinguishable as a whole and the area of interest spans a large part of\n the plot.\n2. DET curves give the user direct feedback of the detection error tradeoff to\n aid in operating point analysis.\n The user can deduct directly from the DET-curve plot at which rate\n false-negative error rate will improve when willing to accept an increase in\n false-positive error rate (or vice-versa).\n\nThe plots in this example compare ROC curves on the left side to corresponding\nDET curves on the right.\nThere is no particular reason why these classifiers have been chosen for the\nexample plot over other classifiers available in scikit-learn.\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>- See :func:`sklearn.metrics.roc_curve` for further information about ROC\n curves.\n\n - See :func:`sklearn.metrics.det_curve` for further information about\n DET curves.\n\n - This example is loosely based on\n `sphx_glr_auto_examples_classification_plot_classifier_comparison.py`\n example.</p></div>\n"
1919
]
2020
},
2121
{
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import matplotlib.pyplot as plt\n\nfrom sklearn.datasets import make_classification\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.metrics import plot_det_curve\nfrom sklearn.metrics import plot_roc_curve\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.svm import LinearSVC\n\nN_SAMPLES = 1000\n\nclassifiers = {\n \"Linear SVM\": make_pipeline(StandardScaler(), LinearSVC(C=0.025)),\n \"Random Forest\": RandomForestClassifier(\n max_depth=5, n_estimators=10, max_features=1\n ),\n}\n\nX, y = make_classification(\n n_samples=N_SAMPLES, n_features=2, n_redundant=0, n_informative=2,\n random_state=1, n_clusters_per_class=1)\n\nX_train, X_test, y_train, y_test = train_test_split(\n X, y, test_size=.4, random_state=0)\n\n# prepare plots\nfig, [ax_roc, ax_det] = plt.subplots(1, 2, figsize=(11, 5))\n\nfor name, clf in classifiers.items():\n clf.fit(X_train, y_train)\n\n plot_roc_curve(clf, X_test, y_test, ax=ax_roc, name=name)\n plot_det_curve(clf, X_test, y_test, ax=ax_det, name=name)\n\nax_roc.set_title('Receiver Operating Characteristic (ROC) curves')\nax_det.set_title('Detection Error Tradeoff (DET) curves')\n\nax_roc.grid(linestyle='--')\nax_det.grid(linestyle='--')\n\nplt.legend()\nplt.show()"
29+
"import matplotlib.pyplot as plt\n\nfrom sklearn.datasets import make_classification\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.metrics import DetCurveDisplay\nfrom sklearn.metrics import plot_roc_curve\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.svm import LinearSVC\n\nN_SAMPLES = 1000\n\nclassifiers = {\n \"Linear SVM\": make_pipeline(StandardScaler(), LinearSVC(C=0.025)),\n \"Random Forest\": RandomForestClassifier(\n max_depth=5, n_estimators=10, max_features=1\n ),\n}\n\nX, y = make_classification(\n n_samples=N_SAMPLES, n_features=2, n_redundant=0, n_informative=2,\n random_state=1, n_clusters_per_class=1)\n\nX_train, X_test, y_train, y_test = train_test_split(\n X, y, test_size=.4, random_state=0)\n\n# prepare plots\nfig, [ax_roc, ax_det] = plt.subplots(1, 2, figsize=(11, 5))\n\nfor name, clf in classifiers.items():\n clf.fit(X_train, y_train)\n\n plot_roc_curve(clf, X_test, y_test, ax=ax_roc, name=name)\n DetCurveDisplay.from_estimator(clf, X_test, y_test, ax=ax_det, name=name)\n\nax_roc.set_title('Receiver Operating Characteristic (ROC) curves')\nax_det.set_title('Detection Error Tradeoff (DET) curves')\n\nax_roc.grid(linestyle='--')\nax_det.grid(linestyle='--')\n\nplt.legend()\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/67703ae8c65716668dd87c31a24a069b/plot_det.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
for the same classification task.
99
1010
DET curves are commonly plotted in normal deviate scale.
11-
To achieve this `plot_det_curve` transforms the error rates as returned by the
11+
To achieve this the DET display transforms the error rates as returned by the
1212
:func:`~sklearn.metrics.det_curve` and the axis scale using
1313
:func:`scipy.stats.norm`.
1414
@@ -51,7 +51,7 @@
5151

5252
from sklearn.datasets import make_classification
5353
from sklearn.ensemble import RandomForestClassifier
54-
from sklearn.metrics import plot_det_curve
54+
from sklearn.metrics import DetCurveDisplay
5555
from sklearn.metrics import plot_roc_curve
5656
from sklearn.model_selection import train_test_split
5757
from sklearn.pipeline import make_pipeline
@@ -81,7 +81,7 @@
8181
clf.fit(X_train, y_train)
8282

8383
plot_roc_curve(clf, X_test, y_test, ax=ax_roc, name=name)
84-
plot_det_curve(clf, X_test, y_test, ax=ax_det, name=name)
84+
DetCurveDisplay.from_estimator(clf, X_test, y_test, ax=ax_det, name=name)
8585

8686
ax_roc.set_title('Receiver Operating Characteristic (ROC) curves')
8787
ax_det.set_title('Detection Error Tradeoff (DET) curves')
Binary file not shown.

dev/_downloads/scikit-learn-docs.zip

-15.8 KB
Binary file not shown.
-203 Bytes
-429 Bytes
-302 Bytes
-188 Bytes
-84 Bytes

0 commit comments

Comments
 (0)