From c13ee632133bb942aab0421b4048173bf19e8906 Mon Sep 17 00:00:00 2001 From: Gael Varoquaux Date: Mon, 19 Jun 2023 23:27:27 +0200 Subject: [PATCH 1/5] DOC: a simple implementation of folding --- doc/conf.py | 17 ++++++++++++++++ doc/modules/model_evaluation.rst | 16 +++++++++++++++ .../scikit-learn-modern/static/css/theme.css | 20 +++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index 176a0d8b3a7d1..73e5525c48725 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -299,6 +299,23 @@ # Not showing the search summary makes the search page load faster. html_show_search_summary = False + +rst_prolog = """ +.. |details-start| raw:: html + +
+ + +.. |details-split| raw:: html + + + +.. |details-end| raw:: html + +
+ +""" + # -- Options for LaTeX output ------------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). diff --git a/doc/modules/model_evaluation.rst b/doc/modules/model_evaluation.rst index 670e661d92ef7..9cc1025047802 100644 --- a/doc/modules/model_evaluation.rst +++ b/doc/modules/model_evaluation.rst @@ -162,6 +162,12 @@ the :func:`fbeta_score` function:: >>> grid = GridSearchCV(LinearSVC(dual="auto"), param_grid={'C': [1, 10]}, ... scoring=ftwo_scorer, cv=5) + +|details-start| +**Custom scorer objects** +|details-split| + + The second use case is to build a completely custom scorer object from a simple python function using :func:`make_scorer`, which can take several parameters: @@ -202,13 +208,21 @@ Here is an example of building custom scorers, and of using the >>> score(clf, X, y) -0.69... +|details-end| .. _diy_scoring: Implementing your own scoring object ------------------------------------ + You can generate even more flexible model scorers by constructing your own scoring object from scratch, without using the :func:`make_scorer` factory. + + +|details-start| +**How to build a scorer from scratch** +|details-split| + For a callable to be a scorer, it needs to meet the protocol specified by the following two rules: @@ -249,6 +263,8 @@ the following two rules: ... cv=5, ... n_jobs=-1) # doctest: +SKIP +|details-end| + .. _multimetric_scoring: Using multiple metric evaluation diff --git a/doc/themes/scikit-learn-modern/static/css/theme.css b/doc/themes/scikit-learn-modern/static/css/theme.css index 90cfeb9300490..6a9ec3574a8ee 100644 --- a/doc/themes/scikit-learn-modern/static/css/theme.css +++ b/doc/themes/scikit-learn-modern/static/css/theme.css @@ -147,6 +147,26 @@ div.clearer { clear: both; } +/* details / summary */ +div.sk-page-content summary { + padding: .5ex; + border: .5pt solid #aaa; + width: fit-content; + border-radius: 5pt 5pt 0pt 0pt; + background-color: #edf9ff; +} + +div.sk-page-content summary:hover { + background-color: #f1f1f1; +} + +div.sk-page-content details { + border: solid #ccc; + border-width: 0pt 0pt 0pt 5pt; + padding-left: 3pt; +} + + /* Button */ .sk-btn-primary { From 5b320234ca1524994ed57edc59e82c73a0d9e47d Mon Sep 17 00:00:00 2001 From: Gael Varoquaux Date: Tue, 20 Jun 2023 08:09:27 +0200 Subject: [PATCH 2/5] Style: we actually use bootstrap --- doc/conf.py | 4 ++- .../scikit-learn-modern/static/css/theme.css | 29 ++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 73e5525c48725..de36d88fcc568 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -304,14 +304,16 @@ .. |details-start| raw:: html
- + .. |details-split| raw:: html +
.. |details-end| raw:: html +
""" diff --git a/doc/themes/scikit-learn-modern/static/css/theme.css b/doc/themes/scikit-learn-modern/static/css/theme.css index 6a9ec3574a8ee..db9bb95766135 100644 --- a/doc/themes/scikit-learn-modern/static/css/theme.css +++ b/doc/themes/scikit-learn-modern/static/css/theme.css @@ -148,24 +148,24 @@ div.clearer { } /* details / summary */ -div.sk-page-content summary { - padding: .5ex; - border: .5pt solid #aaa; - width: fit-content; - border-radius: 5pt 5pt 0pt 0pt; - background-color: #edf9ff; -} -div.sk-page-content summary:hover { - background-color: #f1f1f1; +div.sk-page-content details { + margin: 4ex 0pt; } -div.sk-page-content details { - border: solid #ccc; - border-width: 0pt 0pt 0pt 5pt; - padding-left: 3pt; +div.sk-page-content summary.btn { + display: inline list-item; + padding: 6px 20px; } +div.sk-page-content details div.card { + padding: 0pt .5ex; + margin: 1ex 0pt; + border: 1px solid #e9ecef; + border-left-width: .25rem; + border-radius: .25rem; + background: rgb(250, 252, 253) +} /* Button */ @@ -626,6 +626,7 @@ div.sk-sidebar-global-toc ul ul { div.sk-page-content h1 { background-color: #cde8ef; padding: 0.5rem; + margin-top: calc(max(2.5rem, 1vh)); border-radius: 0 1rem; text-align: center; font-size: 2rem; @@ -637,6 +638,7 @@ div.sk-page-content h2 { background-color: #BED4EB; border-radius: 0.3rem; font-size: 1.5rem; + margin-top: calc(max(2rem, .7vh)); margin-bottom: 1rem; word-wrap: break-word; } @@ -647,6 +649,7 @@ div.sk-page-content h3 { border-radius: 0.3rem; font-size: 1.2rem; word-wrap: break-word; + margin-top: 1.5rem; } div.sk-page-content h4 { From 92fb0c7795eeaf948aaebca3243eef9b74e6eb9f Mon Sep 17 00:00:00 2001 From: Gael Varoquaux Date: Tue, 20 Jun 2023 08:11:09 +0200 Subject: [PATCH 3/5] more visible buttons --- doc/themes/scikit-learn-modern/static/css/theme.css | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/themes/scikit-learn-modern/static/css/theme.css b/doc/themes/scikit-learn-modern/static/css/theme.css index db9bb95766135..7196198b5cf2d 100644 --- a/doc/themes/scikit-learn-modern/static/css/theme.css +++ b/doc/themes/scikit-learn-modern/static/css/theme.css @@ -156,6 +156,7 @@ div.sk-page-content details { div.sk-page-content summary.btn { display: inline list-item; padding: 6px 20px; + border: 1pt solid #999; } div.sk-page-content details div.card { From 6ee6af2e87205b21763821fe0676e9629ae75486 Mon Sep 17 00:00:00 2001 From: Gael Varoquaux Date: Tue, 20 Jun 2023 10:04:25 +0200 Subject: [PATCH 4/5] Work on chrome and firefox --- doc/themes/scikit-learn-modern/static/css/theme.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/themes/scikit-learn-modern/static/css/theme.css b/doc/themes/scikit-learn-modern/static/css/theme.css index 7196198b5cf2d..520f39cc3db9d 100644 --- a/doc/themes/scikit-learn-modern/static/css/theme.css +++ b/doc/themes/scikit-learn-modern/static/css/theme.css @@ -154,7 +154,7 @@ div.sk-page-content details { } div.sk-page-content summary.btn { - display: inline list-item; + display: list-item; padding: 6px 20px; border: 1pt solid #999; } From dd3d76b856509da567e0ba7ac26e4d0fa50d9aab Mon Sep 17 00:00:00 2001 From: Gael Varoquaux Date: Wed, 21 Jun 2023 07:48:13 +0200 Subject: [PATCH 5/5] Add tooltips --- doc/conf.py | 1 + .../scikit-learn-modern/static/css/theme.css | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index de36d88fcc568..6ac1b4e231822 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -308,6 +308,7 @@ .. |details-split| raw:: html + Click for more details
diff --git a/doc/themes/scikit-learn-modern/static/css/theme.css b/doc/themes/scikit-learn-modern/static/css/theme.css index 520f39cc3db9d..fb729223b57ab 100644 --- a/doc/themes/scikit-learn-modern/static/css/theme.css +++ b/doc/themes/scikit-learn-modern/static/css/theme.css @@ -168,6 +168,40 @@ div.sk-page-content details div.card { background: rgb(250, 252, 253) } +div.sk-page-content summary { + position: relative; /* Needed for the tooltips */ +} + +div.sk-page-content summary .tooltiptext { + visibility: hidden; + width: 120px; + background-color: black; + color: #fff; + text-align: center; + border-radius: 6px; + padding: 5px 0; + position: absolute; + z-index: 1; + bottom: 150%; + left: 50%; + margin-left: -60px; +} + +div.sk-page-content summary .tooltiptext::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: black transparent transparent transparent; +} + +div.sk-page-content summary:hover .tooltiptext { + visibility: visible; +} + /* Button */ .sk-btn-primary {