8000 CLN Renames to display · thomasjpfan/scikit-learn@fab9d07 · GitHub
[go: up one dir, main page]

Skip to content

Commit fab9d07

Browse files
committed
CLN Renames to display
1 parent 2e8db1f commit fab9d07

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

doc/developers/contributing.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,24 +1657,24 @@ Plotting API
16571657
Scikit-learn defines a simple API for creating visualizations for machine
16581658
learning. The key features of this API is to run calculations once and to have
16591659
the flexibility to adjust the visualizations after the fact. This logic is
1660-
encapsulated into a visualizer object where the computed data is stored and
1661-
the plotting is done in a `plot` method. The visualizer object's `__init__`
1660+
encapsulated into a display object where the computed data is stored and
1661+
the plotting is done in a `plot` method. The display object's `__init__`
16621662
method contains only the data needed to create the visualization. The `plot`
16631663
method takes in parameters that only have to do with visualization, such as a
16641664
matplotlib axes. The `plot` method will store the matplotlib artists as
1665-
attributes allowing for style adjustments through the visualizer object. A
1665+
attributes allowing for style adjustments through the display object. A
16661666
`plot_*` helper function accepts parameters to do the computation and the
1667-
parameters used for plotting. After the helper function creates the visualizer
1668-
with the computed values, it calls the visualizer's plot method. Note that the
1669-
`plot` method defines attributes related to matplotlib, such as the line
1670-
artist. This allows for customizations after calling the `plot` method.
1667+
parameters used for plotting. After the helper function creates the display
1668+
object with the computed values, it calls the display's plot method. Note
1669+
that the `plot` method defines attributes related to matplotlib, such as the
1670+
line artist. This allows for customizations after calling the `plot` method.
16711671

1672-
For example, the `RocCurveVisualizer` defines the following methods and
1672+
For example, the `RocCurveDisplay` defines the following methods and
16731673
attributes:
16741674

16751675
.. code-block:: python
16761676
1677-
class RocCurveVisualizer:
1677+
class RocCurveDisplay:
16781678
def __init__(self, fpr, tpr, roc_auc, estimator_name):
16791679
...
16801680
self.fpr = fpr
@@ -1692,7 +1692,7 @@ attributes:
16921692
drop_intermediate=True, response_method="auto",
16931693
name=None, ax=None, **kwargs):
16941694
# do computation
1695-
viz = RocCurveVisualizer(fpr, tpr, roc_auc,
1695+
viz = RocCurveDisplay(fpr, tpr, roc_auc,
16961696
estimator.__class__.__name__)
16971697
return viz.plot(ax=ax, name=name, **kwargs)
16981698
```

doc/modules/classes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ See the :ref:`visualizations` section of the user guide for further details.
10241024
:toctree: generated/
10251025
:template: class.rst
10261026

1027-
metrics.RocCurveVisualizer
1027+
metrics.RocCurveDisplay
10281028

10291029

10301030
.. _mixture_ref:

doc/visualizations.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ ROC curve for a fitted support vector machine:
2222
svc = SVC(random_state=42)
2323
svc.fit(X_train, y_train)
2424
25-
viz_svc = plot_roc_curve(svc, X_test, y_test)
25+
svc_disp = plot_roc_curve(svc, X_test, y_test)
2626
27-
.. figure:: ../auto_examples/images/sphx_glr_plot_roc_curve_visualizer_001.png
28-
:target: ../auto_examples/plot_roc_curve_visualizer.html
27+
.. figure:: ../auto_examples/images/sphx_glr_plot_roc_curve_visualization_api_001.png
28+
:target: ../auto_examples/plot_roc_curve_visualization_api.html
2929
:align: center
3030
:scale: 75%
3131

32-
The returned `viz_svc` object allows us to continue using the already computed
33-
ROC curve for SVC in future plots. In this case, the `viz_svc` is a
34-
:class:`~sklearn.metrics.RocCurveVisualizer` that stores the computed values as
32+
The returned `svc_disp` object allows us to continue using the already computed
33+
ROC curve for SVC in future plots. In this case, the `svc_disp` is a
34+
:class:`~sklearn.metrics.RocCurveDisplay` that stores the computed values as
3535
attributes called `roc_auc`, `fpr`, and `tpr`. Next, we train a random forest
3636
classifier and plot the previously computed roc curve again by using the `plot`
37-
method of the `Visualizer` object.
37+
method of the `Display` object.
3838

3939
.. code-block:: python
4040
@@ -45,11 +45,11 @@ method of the `Visualizer` object.
4545
rfc.fit(X_train, y_train)
4646
4747
ax = plt.gca()
48-
viz_rfc = plot_roc_curve(rfc, X_test, y_test, ax=ax, alpha=0.8)
49-
viz_svc.plot(ax=ax, alpha=0.8)
48+
rfc_disp = plot_roc_curve(rfc, X_test, y_test, ax=ax, alpha=0.8)
49+
svc_disp.plot(ax=ax, alpha=0.8)
5050
51-
.. figure:: ../auto_examples/images/sphx_glr_plot_roc_curve_visualizer_002.png
52-
:target: ../auto_examples/plot_roc_curve_visualizer.html
51+
.. figure:: ../auto_examples/images/sphx_glr_plot_roc_curve_visualization_api_002.png
52+
:target: ../auto_examples/plot_roc_curve_visualization_api.html
5353
:align: center
5454
:scale: 75%
5555

@@ -58,7 +58,7 @@ values of the curves.
5858

5959
.. topic:: Examples:
6060

61-
* :ref:`sphx_glr_auto_examples_plot_roc_curve_visualizer.py`
61+
* :ref:`sphx_glr_auto_examples_plot_roc_curve_visualization_api.py`
6262

6363
Available Plotting Utilities
6464
============================
@@ -73,11 +73,11 @@ Fucntions
7373
metrics.plot_roc_curve
7474

7575

76-
Visualizers
77-
-----------
76+
Display Objects
77+
---------------
7878

7979
.. currentmodule:: sklearn
8080

8181
.. autosummary::
8282

83-
metrics.RocCurveVisualizer
83+
metrics.RocCurveDisplay

examples/plot_roc_curve_visualizer.py renamed to examples/plot_roc_curve_visualization_api.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
==========================
3-
ROC Curve with Visualizers
4-
==========================
2+
================================
3+
ROC Curve with Visualization API
4+
================================
55
Scikit-learn defines a simple API for creating visualizations for machine
66
learning. The key features of this API is to allow for quick plotting and
77
visual adjustments without recalculation. In this example, we will demonstrate
@@ -32,24 +32,24 @@
3232
# Plotting the ROC Curve
3333
# ----------------------
3434
# Next, we plot the ROC curve with a single call to
35-
# :func:`sklearn.metrics.plot_roc_curve`. The returned `viz_svc` object allows
35+
# :func:`sklearn.metrics.plot_roc_curve`. The returned `svc_disp` object allows
3636
# us to continue using the already computed ROC curve for the SVC in future
3737
# plots.
38-
viz_svc = plot_roc_curve(svc, X_test, y_test)
38+
svc_disp = plot_roc_curve(svc, X_test, y_test)
3939
plt.show()
4040

4141
##############################################################################
4242
# Training a Random Forest and Plotting the ROC Curve
4343
# --------------------------------------------------------
4444
# We train a random forest classifier and create a plot comparing it to the SVC
45-
# ROC curve. Notice how `viz_svc` uses
46-
# :func:`~sklearn.metrics.RocCurveVisualizer.plot` to plot the SVC ROC curve
47-
# without recomputing the values of the roc curve itself. Futhermore, how we
45+
# ROC curve. Notice how `svc_disp` uses
46+
# :func:`~sklearn.metrics.RocCurveDisplay.plot` to plot the SVC ROC curve
47+
# without recomputing the values of the roc curve itself. Futhermore, we
4848
# pass `alpha=0.8` to the plot functions to adjust the alpha values of the
4949
# curves.
5050
rfc = RandomForestClassifier(n_estimators=10, random_state=42)
5151
rfc.fit(X_train, y_train)
5252
ax = plt.gca()
53-
viz_rfc = plot_roc_curve(rfc, X_test, y_test, ax=ax, alpha=0.8)
54-
viz_svc.plot(ax=ax, alpha=0.8)
53+
rfc_disp = plot_roc_curve(rfc, X_test, y_test, ax=ax, alpha=0.8)
54+
svc_disp.plot(ax=ax, alpha=0.8)
5555
plt.show()

sklearn/metrics/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
from .scorer import get_scorer
7676

7777
from ._plot.roc_curve import plot_roc_curve
78-
from ._plot.roc_curve import RocCurveVisualizer
78+
from ._plot.roc_curve import RocCurveDisplay
7979

8080

8181
__all__ = [
@@ -135,7 +135,7 @@
135135
'precision_score',
136136
'r2_score',
137137
'recall_score',
138-
'RocCurveVisualizer',
138+
'RocCurveDisplay',
139139
'roc_auc_score',
140140
'roc_curve',
141141
'SCORERS',

sklearn/metrics/_plot/roc_curve.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ...utils import check_matplotlib_support
55

66

7-
class RocCurveVisualizer:
7+
class RocCurveDisplay:
88
"""ROC Curve visualization.
99
1010
It is recommend to use `sklearn.metrics.plot_roc_curve` to create a
@@ -122,7 +122,7 @@ def plot_roc_curve(estimator, X, y, pos_label=None, sample_weight=None,
122122
123123
Returns
124124
-------
125-
viz : :class:`sklearn.metrics.plot.RocCurveVisualizer`
125+
viz : :class:`sklearn.metrics.plot.RocCurveDisplay`
126126
object that stores computed values
127127
"""
128128
if response_method not in ("predict_proba", "decision_function", "auto"):
@@ -151,5 +151,5 @@ def plot_roc_curve(estimator, X, y, pos_label=None, sample_weight=None,
151151
fpr, tpr, _ = roc_curve(y, y_pred, pos_label=pos_label,
152152
drop_intermediate=drop_intermediate)
153153
roc_auc = auc(fpr, tpr)
154-
viz = RocCurveVisualizer(fpr, tpr, roc_auc, estimator.__class__.__name__)
154+
viz = RocCurveDisplay(fpr, tpr, roc_auc, estimator.__class__.__name__)
155155
return viz.plot(ax=ax, name=name, **kwargs)

0 commit comments

Comments
 (0)
0