File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ Version 1.1.2
12
12
Changelog
13
13
---------
14
14
15
+ - |Fix | A default HTML representation is shown for meta-estimators with invalid
16
+ parameters. :pr: `24015 ` by `Thomas Fan `_.
17
+
15
18
:mod: `sklearn.cluster `
16
19
......................
17
20
Original file line number Diff line number Diff line change 1
1
from contextlib import closing
2
- from contextlib import suppress
3
2
from io import StringIO
4
3
from string import Template
5
4
import html
@@ -103,8 +102,16 @@ def _write_label_html(
103
102
104
103
def _get_visual_block (estimator ):
105
104
"""Generate information about how to display an estimator."""
106
- with suppress (AttributeError ):
107
- return estimator ._sk_visual_block_ ()
105
+ if hasattr (estimator , "_sk_visual_block_" ):
106
+ try :
107
+ return estimator ._sk_visual_block_ ()
108
+ except Exception :
109
+ return _VisualBlock (
110
+ "single" ,
111
+ estimator ,
112
+ names = estimator .__class__ .__name__ ,
113
+ name_details = str (estimator ),
114
+ )
108
115
109
116
if isinstance (estimator , str ):
110
117
return _VisualBlock (
Original file line number Diff line number Diff line change @@ -309,3 +309,14 @@ def test_show_arrow_pipeline():
309
309
'class="sk-toggleable__label sk-toggleable__label-arrow">Pipeline'
310
310
in html_output
311
311
)
312
+
313
+
314
+ def test_invalid_parameters_in_stacking ():
315
+ """Invalidate stacking configuration uses default repr.
316
+
317
+ Non-regression test for #24009.
318
+ """
319
+ stacker = StackingClassifier (estimators = [])
320
+
321
+ html_output = estimator_html_repr (stacker )
322
+ assert html .escape (str (stacker )) in html_output
You can’t perform that action at this time.
0 commit comments