Skip to content

Commit c1adbac

Browse files
authored
DOC [PST] fix dropdowns (#28401)
1 parent b9f8f27 commit c1adbac

File tree

72 files changed

+4822
-5448
lines changed

Some content is hidden

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

72 files changed

+4822
-5448
lines changed

doc/common_pitfalls.rst

+33-36
Original file line numberDiff line numberDiff line change
@@ -408,43 +408,40 @@ it will allow the estimator RNG to vary for each fold.
408408
illustration purpose: what matters is what we pass to the
409409
:class:`~sklearn.ensemble.RandomForestClassifier` estimator.
410410

411-
|details-start|
412-
**Cloning**
413-
|details-split|
411+
.. dropdown:: Cloning
412+
413+
Another subtle side effect of passing `RandomState` instances is how
414+
:func:`~sklearn.base.clone` will work::
415+
416+
>>> from sklearn import clone
417+
>>> from sklearn.ensemble import RandomForestClassifier
418+
>>> import numpy as np
419+
420+
>>> rng = np.random.RandomState(0)
421+
>>> a = RandomForestClassifier(random_state=rng)
422+
>>> b = clone(a)
423+
424+
Since a `RandomState` instance was passed to `a`, `a` and `b` are not clones
425+
in the strict sense, but rather clones in the statistical sense: `a` and `b`
426+
will still be different models, even when calling `fit(X, y)` on the same
427+
data. Moreover, `a` and `b` will influence each-other since they share the
428+
same internal RNG: calling `a.fit` will consume `b`'s RNG, and calling
429+
`b.fit` will consume `a`'s RNG, since they are the same. This bit is true for
430+
any estimators that share a `random_state` parameter; it is not specific to
431+
clones.
432+
433+
If an integer were passed, `a` and `b` would be exact clones and they would not
434+
influence each other.
435+
436+
.. warning::
437+
Even though :func:`~sklearn.base.clone` is rarely used in user code, it is
438+
called pervasively throughout scikit-learn codebase: in particular, most
439+
meta-estimators that accept non-fitted estimators call
440+
:func:`~sklearn.base.clone` internally
441+
(:class:`~sklearn.model_selection.GridSearchCV`,
442+
:class:`~sklearn.ensemble.StackingClassifier`,
443+
:class:`~sklearn.calibration.CalibratedClassifierCV`, etc.).
414444

415-
Another subtle side effect of passing `RandomState` instances is how
416-
:func:`~sklearn.base.clone` will work::
417-
418-
>>> from sklearn import clone
419-
>>> from sklearn.ensemble import RandomForestClassifier
420-
>>> import numpy as np
421-
422-
>>> rng = np.random.RandomState(0)
423-
>>> a = RandomForestClassifier(random_state=rng)
424-
>>> b = clone(a)
425-
426-
Since a `RandomState` instance was passed to `a`, `a` and `b` are not clones
427-
in the strict sense, but rather clones in the statistical sense: `a` and `b`
428-
will still be different models, even when calling `fit(X, y)` on the same
429-
data. Moreover, `a` and `b` will influence each-other since they share the
430-
same internal RNG: calling `a.fit` will consume `b`'s RNG, and calling
431-
`b.fit` will consume `a`'s RNG, since they are the same. This bit is true for
432-
any estimators that share a `random_state` parameter; it is not specific to
433-
clones.
434-
435-
If an integer were passed, `a` and `b` would be exact clones and they would not
436-
influence each other.
437-
438-
.. warning::
439-
Even though :func:`~sklearn.base.clone` is rarely used in user code, it is
440-
called pervasively throughout scikit-learn codebase: in particular, most
441-
meta-estimators that accept non-fitted estimators call
442-
:func:`~sklearn.base.clone` internally
443-
(:class:`~sklearn.model_selection.GridSearchCV`,
444-
:class:`~sklearn.ensemble.StackingClassifier`,
445-
:class:`~sklearn.calibration.CalibratedClassifierCV`, etc.).
446-
447-
|details-end|
448445

449446
CV splitters
450447
............

doc/conf.py

+3-24
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"allow_nan_estimators",
6969
"autoshortsummary",
7070
"doi_role",
71+
"dropdown_anchors",
7172
"move_gallery_links",
7273
"override_pst_pagetoc",
7374
"sphinx_issues",
@@ -321,7 +322,7 @@
321322

322323
# Additional JS files
323324
html_js_files = [
324-
"scripts/details-permalink.js",
325+
"scripts/dropdown.js",
325326
"scripts/version-switcher.js",
326327
]
327328

@@ -450,28 +451,6 @@ def add_js_css_files(app, pagename, templatename, context, doctree):
450451
html_show_search_summary = True
451452

452453

453-
# The "summary-anchor" IDs will be overwritten via JavaScript to be unique.
454-
# See `doc/js/scripts/details-permalink.js`.
455-
rst_prolog = """
456-
.. |details-start| raw:: html
457-
458-
<details id="summary-anchor">
459-
<summary class="btn btn-light">
460-
461-
.. |details-split| raw:: html
462-
463-
<span class="tooltiptext">Click for more details</span>
464-
<a class="headerlink" href="#summary-anchor" title="Permalink to this heading">¶</a>
465-
</summary>
466-
<div class="card">
467-
468-
.. |details-end| raw:: html
469-
470-
</div>
471-
</details>
472-
473-
"""
474-
475454
# -- Options for LaTeX output ------------------------------------------------
476455
latex_elements = {
477456
# The paper size ('letterpaper' or 'a4paper').
@@ -777,7 +756,7 @@ def setup(app):
777756
# triggered just before the HTML for an individual page is created
778757
app.connect("html-page-context", add_js_css_files)
779758

780-
# to hide/show the prompt in code examples:
759+
# to hide/show the prompt in code examples
781760
app.connect("build-finished", make_carousel_thumbs)
782761
app.connect("build-finished", filter_search_index)
783762

doc/datasets/loading_other_datasets.rst

+9-10
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ and pipelines on 2D data.
3333
if you plan to use ``matplotlib.pyplpt.imshow``, don't forget to scale to the range
3434
0 - 1 as done in the following example.
3535

36-
.. topic:: Examples:
36+
.. rubric:: Examples
3737

38-
* :ref:`sphx_glr_auto_examples_cluster_plot_color_quantization.py`
38+
* :ref:`sphx_glr_auto_examples_cluster_plot_color_quantization.py`
3939

4040
.. _libsvm_loader:
4141

@@ -68,11 +68,10 @@ features::
6868
... "/path/to/test_dataset.txt", n_features=X_train.shape[1])
6969
... # doctest: +SKIP
7070

71-
.. topic:: Related links:
71+
.. rubric:: Related links
7272

73-
_`Public datasets in svmlight / libsvm format`: https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets
74-
75-
_`Faster API-compatible implementation`: https://github.com/mblondel/svmlight-loader
73+
- `Public datasets in svmlight / libsvm format`: https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets
74+
- `Faster API-compatible implementation`: https://github.com/mblondel/svmlight-loader
7675

7776
..
7877
For doctests:
@@ -215,11 +214,11 @@ identifies the dataset::
215214
'969'
216215

217216

218-
.. topic:: References:
217+
.. rubric:: References
219218

220-
* :arxiv:`Vanschoren, van Rijn, Bischl and Torgo. "OpenML: networked science in
221-
machine learning" ACM SIGKDD Explorations Newsletter, 15(2), 49-60, 2014.
222-
<1407.7722>`
219+
* :arxiv:`Vanschoren, van Rijn, Bischl and Torgo. "OpenML: networked science in
220+
machine learning" ACM SIGKDD Explorations Newsletter, 15(2), 49-60, 2014.
221+
<1407.7722>`
223222

224223
.. _openml_parser:
225224

0 commit comments

Comments
 (0)