Skip to content

DOC [PST] fix dropdowns #28401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2399f21
[doc build] fix dropdowns
Charlie-XIAO Feb 12, 2024
ac2057a
Remove my stupid breakpoint
Charlie-XIAO Feb 12, 2024
ca100a0
change to use post_transform for higher efficiency
Charlie-XIAO Feb 12, 2024
57a7b6a
change to use post_transform for higher efficiency
Charlie-XIAO Feb 12, 2024
0414c2f
resolve some easy comments
Charlie-XIAO Feb 13, 2024
c6005af
Merge remote-tracking branch 'upstream/new_web_theme' into pst-dropdown
Charlie-XIAO Feb 13, 2024
8b39d34
[doc build] add the collapse/expand all functionality
Charlie-XIAO Feb 17, 2024
c4a42b0
Merge remote-tracking branch 'upstream/new_web_theme' into pst-dropdown
Charlie-XIAO Feb 17, 2024
d8f102d
[doc build] trigger full build
Charlie-XIAO Feb 17, 2024
25b0296
Merge remote-tracking branch 'upstream/new_web_theme' into pst-dropdown
Charlie-XIAO Feb 19, 2024
d902c0a
[doc build] cleanup
Charlie-XIAO Feb 19, 2024
7e0dc9c
[doc build] typo
Charlie-XIAO Feb 19, 2024
5c47c2c
[doc build] fix for summary title containing inline code
Charlie-XIAO Feb 19, 2024
d2318fe
Merge remote-tracking branch 'upstream/new_web_theme' into pst-dropdown
Charlie-XIAO Feb 21, 2024
6f378f0
[doc build] trigger full build
Charlie-XIAO Feb 21, 2024
2b9644f
Merge remote-tracking branch 'upstream/new_web_theme' into pst-dropdown
Charlie-XIAO Feb 22, 2024
3411e1d
[doc build] fix duplicated citation
Charlie-XIAO Feb 22, 2024
cc6d6f9
Merge remote-tracking branch 'upstream/new_web_theme' into pst-dropdown
Charlie-XIAO Mar 11, 2024
d18512a
Merge remote-tracking branch 'upstream/new_web_theme' into pst-dropdown
Charlie-XIAO Mar 12, 2024
301bbb4
[doc build] fix sphinx warning
Charlie-XIAO Mar 15, 2024
e6a63a8
Merge remote-tracking branch 'upstream/new_web_theme' into pst-dropdown
Charlie-XIAO Mar 16, 2024
5761a2b
[doc build] trigger full doc build
Charlie-XIAO Mar 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 33 additions & 36 deletions doc/common_pitfalls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -408,43 +408,40 @@ it will allow the estimator RNG to vary for each fold.
illustration purpose: what matters is what we pass to the
:class:`~sklearn.ensemble.RandomForestClassifier` estimator.

|details-start|
**Cloning**
|details-split|
.. dropdown:: Cloning

Another subtle side effect of passing `RandomState` instances is how
:func:`~sklearn.base.clone` will work::

>>> from sklearn import clone
>>> from sklearn.ensemble import RandomForestClassifier
>>> import numpy as np

>>> rng = np.random.RandomState(0)
>>> a = RandomForestClassifier(random_state=rng)
>>> b = clone(a)

Since a `RandomState` instance was passed to `a`, `a` and `b` are not clones
in the strict sense, but rather clones in the statistical sense: `a` and `b`
will still be different models, even when calling `fit(X, y)` on the same
data. Moreover, `a` and `b` will influence each-other since they share the
same internal RNG: calling `a.fit` will consume `b`'s RNG, and calling
`b.fit` will consume `a`'s RNG, since they are the same. This bit is true for
any estimators that share a `random_state` parameter; it is not specific to
clones.

If an integer were passed, `a` and `b` would be exact clones and they would not
influence each other.

.. warning::
Even though :func:`~sklearn.base.clone` is rarely used in user code, it is
called pervasively throughout scikit-learn codebase: in particular, most
meta-estimators that accept non-fitted estimators call
:func:`~sklearn.base.clone` internally
(:class:`~sklearn.model_selection.GridSearchCV`,
:class:`~sklearn.ensemble.StackingClassifier`,
:class:`~sklearn.calibration.CalibratedClassifierCV`, etc.).

Another subtle side effect of passing `RandomState` instances is how
:func:`~sklearn.base.clone` will work::

>>> from sklearn import clone
>>> from sklearn.ensemble import RandomForestClassifier
>>> import numpy as np

>>> rng = np.random.RandomState(0)
>>> a = RandomForestClassifier(random_state=rng)
>>> b = clone(a)

Since a `RandomState` instance was passed to `a`, `a` and `b` are not clones
in the strict sense, but rather clones in the statistical sense: `a` and `b`
will still be different models, even when calling `fit(X, y)` on the same
data. Moreover, `a` and `b` will influence each-other since they share the
same internal RNG: calling `a.fit` will consume `b`'s RNG, and calling
`b.fit` will consume `a`'s RNG, since they are the same. This bit is true for
any estimators that share a `random_state` parameter; it is not specific to
clones.

If an integer were passed, `a` and `b` would be exact clones and they would not
influence each other.

.. warning::
Even though :func:`~sklearn.base.clone` is rarely used in user code, it is
called pervasively throughout scikit-learn codebase: in particular, most
meta-estimators that accept non-fitted estimators call
:func:`~sklearn.base.clone` internally
(:class:`~sklearn.model_selection.GridSearchCV`,
:class:`~sklearn.ensemble.StackingClassifier`,
:class:`~sklearn.calibration.CalibratedClassifierCV`, etc.).

|details-end|

CV splitters
............
Expand Down
27 changes: 3 additions & 24 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
# See sphinxext/
"allow_nan_estimators",
"doi_role",
"dropdown_anchors",
"move_gallery_links",
"sphinx_issues",
]
Expand Down Expand Up @@ -316,7 +317,7 @@

# Additional JS files
html_js_files = [
"scripts/details-permalink.js",
"scripts/dropdown.js",
"scripts/version-switcher.js",
]

Expand Down Expand Up @@ -432,28 +433,6 @@ def add_js_css_files(app, pagename, templatename, context, doctree):
html_show_search_summary = True


# The "summary-anchor" IDs will be overwritten via JavaScript to be unique.
# See `doc/js/scripts/details-permalink.js`.
rst_prolog = """
.. |details-start| raw:: html

<details id="summary-anchor">
<summary class="btn btn-light">

.. |details-split| raw:: html

<span class="tooltiptext">Click for more details</span>
<a class="headerlink" href="#summary-anchor" title="Permalink to this heading">¶</a>
</summary>
<div class="card">

.. |details-end| raw:: html

</div>
</details>

"""

# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
Expand Down Expand Up @@ -759,7 +738,7 @@ def setup(app):
# triggered just before the HTML for an individual page is created
app.connect("html-page-context", add_js_css_files)

# to hide/show the prompt in code examples:
# to hide/show the prompt in code examples
app.connect("build-finished", make_carousel_thumbs)
app.connect("build-finished", filter_search_index)

Expand Down
19 changes: 9 additions & 10 deletions doc/datasets/loading_other_datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ and pipelines on 2D data.
if you plan to use ``matplotlib.pyplpt.imshow``, don't forget to scale to the range
0 - 1 as done in the following example.

.. topic:: Examples:
.. rubric:: Examples

* :ref:`sphx_glr_auto_examples_cluster_plot_color_quantization.py`
* :ref:`sphx_glr_auto_examples_cluster_plot_color_quantization.py`

.. _libsvm_loader:

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

.. topic:: Related links:
.. rubric:: Related links

_`Public datasets in svmlight / libsvm format`: https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets

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

..
For doctests:
Expand Down Expand Up @@ -215,11 +214,11 @@ identifies the dataset::
'969'


.. topic:: References:
.. rubric:: References

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

.. _openml_parser:

Expand Down
Loading