Skip to content

Commit a1e1971

Browse files
authored
Merge branch 'scikit-learn:main' into submodulev3
2 parents 6801508 + 8357243 commit a1e1971

32 files changed

+501
-228
lines changed

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
# Specify how to identify the prompt when copying code snippets
6969
copybutton_prompt_text = r">>> |\.\.\. "
7070
copybutton_prompt_is_regexp = True
71+
copybutton_exclude = "style"
7172

7273
try:
7374
import jupyterlite_sphinx # noqa: F401

doc/developers/advanced_installation.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,13 @@ console:
229229
For 64-bit Python, configure the build environment by running the following
230230
commands in ``cmd`` or an Anaconda Prompt (if you use Anaconda):
231231

232-
::
232+
.. sphinx-prompt 1.3.0 (used in doc-min-dependencies CI task) does not support `batch` prompt type,
233+
.. so we work around by using a known prompt type and an explicit prompt text.
234+
..
235+
.. prompt:: bash C:\>
233236

234-
$ SET DISTUTILS_USE_SDK=1
235-
$ "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
237+
SET DISTUTILS_USE_SDK=1
238+
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
236239

237240
Replace ``x64`` by ``x86`` to build for 32-bit Python.
238241

doc/install.rst

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,32 @@ Then run:
7171

7272
<div class="highlight">
7373
<pre class="sk-expandable" data-packager="pip" data-os="linux" data-venv="no"
74-
><span class="prompt1">pip3 install -U scikit-learn</span></pre>
75-
74+
><span>pip3 install -U scikit-learn</span></pre>
75+
7676
<pre class="sk-expandable" data-packager="pip" data-os="windows" data-venv="no"
77-
><span class="prompt1">pip install -U scikit-learn</span></pre>
78-
77+
><span>pip install -U scikit-learn</span></pre>
78+
7979
<pre class="sk-expandable" data-packager="pip" data-os="mac" data-venv="no"
80-
><span class="prompt1">pip install -U scikit-learn</span></pre>
81-
80+
><span>pip install -U scikit-learn</span></pre>
81+
8282
<pre class="sk-expandable" data-packager="pip" data-os="linux" data-venv=""
83-
><span class="prompt1">python3 -m venv sklearn-venv</span>
84-
<span class="prompt1">source sklearn-venv/bin/activate</span>
85-
<span class="prompt1">pip3 install -U scikit-learn</span></pre>
86-
83+
><span>python3 -m venv sklearn-venv</span>
84+
<span>source sklearn-venv/bin/activate</span>
85+
<span>pip3 install -U scikit-learn</span></pre>
86+
8787
<pre class="sk-expandable" data-packager="pip" data-os="windows" data-venv=""
88-
><span class="prompt1">python -m venv sklearn-venv</span>
89-
<span class="prompt1">sklearn-venv\Scripts\activate</span>
90-
<span class="prompt1">pip install -U scikit-learn</span></pre>
91-
88+
><span>python -m venv sklearn-venv</span>
89+
<span>sklearn-venv\Scripts\activate</span>
90+
<span>pip install -U scikit-learn</span></pre>
91+
9292
<pre class="sk-expandable" data-packager="pip" data-os="mac" data-venv=""
93-
><span class="prompt1">python -m venv sklearn-venv</span>
94-
<span class="prompt1">source sklearn-venv/bin/activate</span>
95-
<span class="prompt1">pip install -U scikit-learn</span></pre>
93+
><span>python -m venv sklearn-venv</span>
94+
<span>source sklearn-venv/bin/activate</span>
95+
<span>pip install -U scikit-learn</span></pre>
9696

9797
<pre class="sk-expandable" data-packager="conda"
98-
><span class="prompt1">conda create -n sklearn-env -c conda-forge scikit-learn</span>
99-
<span class="prompt1">conda activate sklearn-env</span></pre>
98+
><span>conda create -n sklearn-env -c conda-forge scikit-learn</span>
99+
<span>conda activate sklearn-env</span></pre>
100100
</div>
101101

102102
In order to check your installation you can use
@@ -105,29 +105,29 @@ In order to check your installation you can use
105105

106106
<div class="highlight">
107107
<pre class="sk-expandable" data-packager="pip" data-os="linux" data-venv="no"
108-
><span class="prompt1">python3 -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
109-
<span class="prompt1">python3 -m pip freeze # to see all packages installed in the active virtualenv</span>
110-
<span class="prompt1">python3 -c "import sklearn; sklearn.show_versions()"</span></pre>
108+
><span>python3 -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
109+
<span>python3 -m pip freeze # to see all packages installed in the active virtualenv</span>
110+
<span>python3 -c "import sklearn; sklearn.show_versions()"</span></pre>
111111

112112
<pre class="sk-expandable" data-packager="pip" data-os="windows" data-venv="no"
113-
><span class="prompt1">python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
114-
<span class="prompt1">python -m pip freeze # to see all packages installed in the active virtualenv</span>
115-
<span class="prompt1">python -c "import sklearn; sklearn.show_versions()"</span></pre>
113+
><span>python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
114+
<span>python -m pip freeze # to see all packages installed in the active virtualenv</span>
115+
<span>python -c "import sklearn; sklearn.show_versions()"</span></pre>
116116

117117
<pre class="sk-expandable" data-packager="pip" data-os="mac" data-venv="no"
118-
><span class="prompt1">python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
119-
<span class="prompt1">python -m pip freeze # to see all packages installed in the active virtualenv</span>
120-
<span class="prompt1">python -c "import sklearn; sklearn.show_versions()"</span></pre>
118+
><span>python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
119+
<span>python -m pip freeze # to see all packages installed in the active virtualenv</span>
120+
<span>python -c "import sklearn; sklearn.show_versions()"</span></pre>
121121

122122
<pre class="sk-expandable" data-packager="pip" data-venv=""
123-
><span class="prompt1">python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
124-
<span class="prompt1">python -m pip freeze # to see all packages installed in the active virtualenv</span>
125-
<span class="prompt1">python -c "import sklearn; sklearn.show_versions()"</span></pre>
123+
><span>python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
124+
<span>python -m pip freeze # to see all packages installed in the active virtualenv</span>
125+
<span>python -c "import sklearn; sklearn.show_versions()"</span></pre>
126126

127127
<pre class="sk-expandable" data-packager="conda"
128-
><span class="prompt1">conda list scikit-learn # to see which scikit-learn version is installed</span>
129-
<span class="prompt1">conda list # to see all packages installed in the active conda environment</span>
130-
<span class="prompt1">python -c "import sklearn; sklearn.show_versions()"</span></pre>
128+
><span>conda list scikit-learn # to see which scikit-learn version is installed</span>
129+
<span>conda list # to see all packages installed in the active conda environment</span>
130+
<span>python -c "import sklearn; sklearn.show_versions()"</span></pre>
131131
</div>
132132

133133
Note that in order to avoid potential conflicts with other packages it is
@@ -290,7 +290,7 @@ Note that those solvers are not enabled by default, please refer to the
290290
`scikit-learn-intelex <https://intel.github.io/scikit-learn-intelex/what-is-patching.html>`_
291291
documentation for more details on usage scenarios. Direct export example:
292292

293-
.. prompt:: bash $
293+
.. prompt:: python >>>
294294

295295
from sklearnex.neighbors import NearestNeighbors
296296

@@ -340,6 +340,6 @@ using the ``regedit`` tool:
340340

341341
#. Reinstall scikit-learn (ignoring the previous broken installation):
342342

343-
.. prompt:: python $
343+
.. prompt:: bash $
344344

345345
pip install --exists-action=i scikit-learn

doc/modules/array_api.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ automatically skipped. Therefore it's important to run the tests with the
125125

126126
.. prompt:: bash $
127127

128-
$ pip install array-api-compat # and other libraries as needed
129-
$ pytest -k "array_api" -v
128+
pip install array-api-compat # and other libraries as needed
129+
pytest -k "array_api" -v
130130

131131
Note on MPS device support
132132
--------------------------
@@ -143,7 +143,7 @@ To enable the MPS support in PyTorch, set the environment variable
143143

144144
.. prompt:: bash $
145145

146-
$ PYTORCH_ENABLE_MPS_FALLBACK=1 pytest -k "array_api" -v
146+
PYTORCH_ENABLE_MPS_FALLBACK=1 pytest -k "array_api" -v
147147

148148
At the time of writing all scikit-learn tests should pass, however, the
149149
computational speed is not necessarily better than with the CPU device.

doc/modules/feature_selection.rst

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -201,31 +201,36 @@ alpha parameter, the fewer features selected.
201201

202202
.. _compressive_sensing:
203203

204-
.. topic:: **L1-recovery and compressive sensing**
205-
206-
For a good choice of alpha, the :ref:`lasso` can fully recover the
207-
exact set of non-zero variables using only few observations, provided
208-
certain specific conditions are met. In particular, the number of
209-
samples should be "sufficiently large", or L1 models will perform at
210-
random, where "sufficiently large" depends on the number of non-zero
211-
coefficients, the logarithm of the number of features, the amount of
212-
noise, the smallest absolute value of non-zero coefficients, and the
213-
structure of the design matrix X. In addition, the design matrix must
214-
display certain specific properties, such as not being too correlated.
215-
216-
There is no general rule to select an alpha parameter for recovery of
217-
non-zero coefficients. It can by set by cross-validation
218-
(:class:`~sklearn.linear_model.LassoCV` or
219-
:class:`~sklearn.linear_model.LassoLarsCV`), though this may lead to
220-
under-penalized models: including a small number of non-relevant variables
221-
is not detrimental to prediction score. BIC
222-
(:class:`~sklearn.linear_model.LassoLarsIC`) tends, on the opposite, to set
223-
high values of alpha.
224-
225-
**Reference** Richard G. Baraniuk "Compressive Sensing", IEEE Signal
204+
|details-start|
205+
**L1-recovery and compressive sensing**
206+
|details-split|
207+
208+
For a good choice of alpha, the :ref:`lasso` can fully recover the
209+
exact set of non-zero variables using only few observations, provided
210+
certain specific conditions are met. In particular, the number of
211+
samples should be "sufficiently large", or L1 models will perform at
212+
random, where "sufficiently large" depends on the number of non-zero
213+
coefficients, the logarithm of the number of features, the amount of
214+
noise, the smallest absolute value of non-zero coefficients, and the
215+
structure of the design matrix X. In addition, the design matrix must
216+
display certain specific properties, such as not being too correlated.
217+
218+
There is no general rule to select an alpha parameter for recovery of
219+
non-zero coefficients. It can by set by cross-validation
220+
(:class:`~sklearn.linear_model.LassoCV` or
221+
:class:`~sklearn.linear_model.LassoLarsCV`), though this may lead to
222+
under-penalized models: including a small number of non-relevant variables
223+
is not detrimental to prediction score. BIC
224+
(:class:`~sklearn.linear_model.LassoLarsIC`) tends, on the opposite, to set
225+
high values of alpha.
226+
227+
.. topic:: Reference
228+
229+
Richard G. Baraniuk "Compressive Sensing", IEEE Signal
226230
Processing Magazine [120] July 2007
227231
http://users.isr.ist.utl.pt/~aguiar/CS_notes.pdf
228232

233+
|details-end|
229234

230235
Tree-based feature selection
231236
----------------------------
@@ -282,6 +287,10 @@ instead of starting with no features and greedily adding features, we start
282287
with *all* the features and greedily *remove* features from the set. The
283288
`direction` parameter controls whether forward or backward SFS is used.
284289

290+
|details-start|
291+
**Detail on Sequential Feature Selection**
292+
|details-split|
293+
285294
In general, forward and backward selection do not yield equivalent results.
286295
Also, one may be much faster than the other depending on the requested number
287296
of selected features: if we have 10 features and ask for 7 selected features,
@@ -299,16 +308,18 @@ cross-validation requires fitting `m * k` models, while
299308
:class:`~sklearn.feature_selection.SelectFromModel` always just does a single
300309
fit and requires no iterations.
301310

302-
.. topic:: Examples
303-
304-
* :ref:`sphx_glr_auto_examples_feature_selection_plot_select_from_model_diabetes.py`
305-
306-
.. topic:: References:
311+
.. topic:: Reference
307312

308313
.. [sfs] Ferri et al, `Comparative study of techniques for
309314
large-scale feature selection
310315
<https://citeseerx.ist.psu.edu/doc_view/pid/5fedabbb3957bbb442802e012d829ee0629a01b6>`_.
311316
317+
|details-end|
318+
319+
.. topic:: Examples
320+
321+
* :ref:`sphx_glr_auto_examples_feature_selection_plot_select_from_model_diabetes.py`
322+
312323
Feature selection as part of a pipeline
313324
=======================================
314325

0 commit comments

Comments
 (0)