Skip to content

Commit 3edc4d6

Browse files
DeaMariaLeonglemaitrejeremiedbb
authored
ENH Add a link + tooltip to each parameter docstring in params table display (#31564)
Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai> Co-authored-by: Jérémie du Boisberranger <jeremie@probabl.ai>
1 parent 90338a4 commit 3edc4d6

File tree

8 files changed

+1078
-28
lines changed

8 files changed

+1078
-28
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- The parameter table in the HTML representation of all scikit-learn estimators and
2+
more generally of estimators inheriting from :class:`base.BaseEstimator`
3+
now displays the parameter description as a tooltip and has a link to the online
4+
documentation for each parameter.
5+
By :user:`Dea María Léon <DeaMariaLeon>`.

sklearn/base.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def get_params(self, deep=True):
261261
out[key] = value
262262
return out
263263

264-
def _get_params_html(self, deep=True):
264+
def _get_params_html(self, deep=True, doc_link=""):
265265
"""
266266
Get parameters for this estimator with a specific HTML representation.
267267
@@ -271,6 +271,11 @@ def _get_params_html(self, deep=True):
271271
If True, will return the parameters for this estimator and
272272
contained subobjects that are estimators.
273273
274+
doc_link : str
275+
URL to the estimator documentation.
276+
Used for linking to the estimator's parameters documentation
277+
available in HTML displays.
278+
274279
Returns
275280
-------
276281
params : ParamsDict
@@ -319,7 +324,12 @@ def is_non_default(param_name, param_value):
319324
[name for name, value in ordered_out.items() if is_non_default(name, value)]
320325
)
321326

322-
return ParamsDict(ordered_out, non_default=non_default_ls)
327+
return ParamsDict(
328+
params=ordered_out,
329+
non_default=non_default_ls,
330+
estimator_class=self.__class__,
331+
doc_link=doc_link,
332+
)
323333

324334
def set_params(self, **params):
325335
"""Set the parameters of this estimator.

0 commit comments

Comments
 (0)