Skip to content

Commit d3db181

Browse files
authored
Merge branch 'scikit-learn:main' into my-new-branch
2 parents ca5dfdb + 907c093 commit d3db181

Some content is hidden

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

61 files changed

+2795
-947
lines changed

build_tools/github/build_wheels.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ set -x
77
if [[ "$RUNNER_OS" == "macOS" ]]; then
88
# Make sure to use a libomp version binary compatible with the oldest
99
# supported version of the macos SDK as libomp will be vendored into the
10-
# scikit-learn wheels for macos. The list of bottles can be found at:
11-
# https://formulae.brew.sh/api/formula/libomp.json. Currently, the oldest
10+
# scikit-learn wheels for macos. The list of binaries are in
11+
# https://packages.macports.org/libomp/. Currently, the oldest
1212
# supported macos version is: High Sierra / 10.13. When upgrading this, be
1313
# sure to update the MACOSX_DEPLOYMENT_TARGET environment variable in
14-
# wheels.yml accordingly.
15-
wget https://homebrew.bintray.com/bottles/libomp-11.0.0.high_sierra.bottle.tar.gz
16-
brew install libomp-11.0.0.high_sierra.bottle.tar.gz
14+
# wheels.yml accordingly. Note that Darwin_17 == High Sierra / 10.13.
15+
wget https://packages.macports.org/libomp/libomp-12.0.0_0+universal.darwin_17.i386-x86_64.tbz2 -O libomp.tbz2
16+
sudo tar -C / -xvjf libomp.tbz2 opt
17+
1718
export CC=/usr/bin/clang
1819
export CXX=/usr/bin/clang++
1920
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
20-
export CFLAGS="$CFLAGS -I/usr/local/opt/libomp/include"
21-
export CXXFLAGS="$CXXFLAGS -I/usr/local/opt/libomp/include"
22-
export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/local/opt/libomp/lib -L/usr/local/opt/libomp/lib -lomp"
21+
export CFLAGS="$CFLAGS -I/opt/local/include/libomp"
22+
export CXXFLAGS="$CXXFLAGS -I/opt/local/include/libomp"
23+
export LDFLAGS="$LDFLAGS -Wl,-rpath,/opt/local/lib/libomp -L/opt/local/lib/libomp -lomp"
2324
fi
2425

2526
# The version of the built dependencies are specified

doc/conf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
from github_link import make_linkcode_resolve
3131
import sphinx_gallery
32+
import matplotlib as mpl
3233

3334
# -- General configuration ---------------------------------------------------
3435

@@ -49,6 +50,21 @@
4950
"sphinxext.opengraph",
5051
]
5152

53+
# Support for `plot::` directives in sphinx 3.2 requires matplotlib 3.1.0 or newer
54+
if parse(mpl.__version__) >= parse("3.1.0"):
55+
extensions.append("matplotlib.sphinxext.plot_directive")
56+
57+
# Produce `plot::` directives for examples that contain `import matplotlib` or
58+
# `from matplotlib import`.
59+
numpydoc_use_plots = True
60+
61+
# Options for the `::plot` directive:
62+
# https://matplotlib.org/stable/api/sphinxext_plot_directive_api.html
63+
plot_formats = ["png"]
64+
plot_include_source = True
65+
plot_html_show_formats = False
66+
plot_html_show_source_link = False
67+
5268
# this is needed for some reason...
5369
# see https://github.com/numpy/numpydoc/issues/69
5470
numpydoc_class_members_toctree = False

doc/modules/calibration.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,25 @@ approximately 80% actually belong to the positive class.
3030
Calibration curves
3131
------------------
3232

33-
The following plot compares how well the probabilistic predictions of
34-
different classifiers are calibrated, using :func:`calibration_curve`.
33+
Calibration curves (also known as reliability diagrams) compare how well the
34+
probabilistic predictions of a binary classifier are calibrated. It plots
35+
the true frequency of the positive label against its predicted probability,
36+
for binned predictions.
3537
The x axis represents the average predicted probability in each bin. The
3638
y axis is the *fraction of positives*, i.e. the proportion of samples whose
37-
class is the positive class (in each bin).
39+
class is the positive class (in each bin). The top calibration curve plot
40+
is created with :func:`CalibrationDisplay.from_estimators`, which uses
41+
:func:`calibration_curve` to calculate the per bin average predicted
42+
probabilities and fraction of positives.
43+
:func:`CalibrationDisplay.from_estimator`
44+
takes as input a fitted classifier, which is used to calculate the predicted
45+
probabilities. The classifier thus must have :term:`predict_proba` method. For
46+
the few classifiers that do not have a :term:`predict_proba` method, it is
47+
possible to use :class:`CalibratedClassifierCV` to calibrate the classifier
48+
outputs to probabilities.
49+
50+
The bottom histogram gives some insight into the behavior of each classifier
51+
by showing the number of samples in each predicted probability bin.
3852

3953
.. figure:: ../auto_examples/calibration/images/sphx_glr_plot_compare_calibration_001.png
4054
:target: ../auto_examples/calibration/plot_compare_calibration.html
@@ -161,6 +175,8 @@ mean a better calibrated model.
161175
:class:`CalibratedClassifierCV` supports the use of two 'calibration'
162176
regressors: 'sigmoid' and 'isotonic'.
163177

178+
.. _sigmoid_regressor:
179+
164180
Sigmoid
165181
^^^^^^^
166182

doc/modules/classes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ See the :ref:`visualizations` section of the user guide for further details.
11231123
metrics.DetCurveDisplay
11241124
metrics.PrecisionRecallDisplay
11251125
metrics.RocCurveDisplay
1126-
1126+
calibration.CalibrationDisplay
11271127

11281128
.. _mixture_ref:
11291129

doc/modules/model_evaluation.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,10 @@ score:
796796

797797
Note that the :func:`precision_recall_curve` function is restricted to the
798798
binary case. The :func:`average_precision_score` function works only in
799-
binary classification and multilabel indicator format. The
800-
:func:`plot_precision_recall_curve` function plots the precision recall as
801-
follows.
799+
binary classification and multilabel indicator format.
800+
The :func:`PredictionRecallDisplay.from_estimator` and
801+
:func:`PredictionRecallDisplay.from_predictions` functions will plot the
802+
precision-recall curve as follows.
802803

803804
.. image:: ../auto_examples/model_selection/images/sphx_glr_plot_precision_recall_001.png
804805
:target: ../auto_examples/model_selection/plot_precision_recall.html#plot-the-precision-recall-curve

doc/visualizations.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ values of the curves.
6565
* :ref:`sphx_glr_auto_examples_miscellaneous_plot_roc_curve_visualization_api.py`
6666
* :ref:`sphx_glr_auto_examples_miscellaneous_plot_partial_dependence_visualization_api.py`
6767
* :ref:`sphx_glr_auto_examples_miscellaneous_plot_display_object_visualization.py`
68+
* :ref:`sphx_glr_auto_examples_calibration_plot_compare_calibration.py`
6869

6970
Available Plotting Utilities
7071
============================
@@ -90,6 +91,7 @@ Display Objects
9091

9192
.. autosummary::
9293

94+
calibration.CalibrationDisplay
9395
inspection.PartialDependenceDisplay
9496
metrics.ConfusionMatrixDisplay
9597
metrics.DetCurveDisplay

doc/whats_new/v1.0.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,14 @@ Changelog
152152
:class:`calibration.CalibratedClassifierCV` can now properly be used on
153153
prefitted pipelines. :pr:`19641` by :user:`Alek Lefebvre <AlekLefebvre>`.
154154

155+
- |Feature| :func:`calibration.CalibrationDisplay` added to plot
156+
calibration curves. :pr:`17443` by :user:`Lucy Liu <lucyleeow>`.
157+
155158
- |Fix| Fixed an error when using a ::class:`ensemble.VotingClassifier`
156159
as `base_estimator` in ::class:`calibration.CalibratedClassifierCV`.
157160
:pr:`20087` by :user:`Clément Fauchereau <clement-f>`.
158161

162+
159163
:mod:`sklearn.cluster`
160164
......................
161165

@@ -585,6 +589,14 @@ Changelog
585589
class methods and will be removed in 1.2.
586590
:pr:`18543` by `Guillaume Lemaitre`_.
587591

592+
- |API| :class:`metrics.PrecisionRecallDisplay` exposes two class methods
593+
:func:`~metrics.PrecisionRecallDisplay.from_estimator` and
594+
:func:`~metrics.PrecisionRecallDisplay.from_predictions` allowing to create
595+
a precision-recall curve using an estimator or the predictions.
596+
:func:`metrics.plot_precision_recall_curve` is deprecated in favor of these
597+
two class methods and will be removed in 1.2.
598+
:pr:`20552` by `Guillaume Lemaitre`_.
599+
588600
- |API| :class:`metrics.DetCurveDisplay` exposes two class methods
589601
:func:`~metrics.DetCurveDisplay.from_estimator` and
590602
:func:`~metrics.DetCurveDisplay.from_predictions` allowing to create
@@ -764,6 +776,14 @@ Changelog
764776
for non-English characters. :pr:`18959` by :user:`Zero <Zeroto521>`
765777
and :user:`wstates <wstates>`.
766778

779+
780+
:mod:`sklearn.feature_extraction`
781+
..................................
782+
783+
- |Fix| Fixed a bug in :func:`image._to_graph` where singleton
784+
connected components were not handled properly, resulting in a wrong
785+
vertex indexing. :pr:`18964` by `Bertrand Thirion`_.
786+
767787
- |Fix| Fixed a bug in :class:`tree.DecisionTreeClassifier`,
768788
:class:`tree.DecisionTreeRegressor` where a node could be split whereas it
769789
should not have been due to incorrect handling of rounding errors.

0 commit comments

Comments
 (0)