From b05bab2925772d24b3b655227e9088541c2f2e33 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Thu, 25 Feb 2021 16:03:18 -0500 Subject: [PATCH 1/3] ENH Adds final_estimator in html repr for Stacking --- sklearn/ensemble/_stacking.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sklearn/ensemble/_stacking.py b/sklearn/ensemble/_stacking.py index 303015cc9f751..3fe796a7debd5 100644 --- a/sklearn/ensemble/_stacking.py +++ b/sklearn/ensemble/_stacking.py @@ -250,9 +250,11 @@ def _sk_visual_block_(self, final_estimator): names, estimators = zip(*self.estimators) parallel = _VisualBlock('parallel', estimators, names=names, dash_wrapped=False) - serial = _VisualBlock('serial', (parallel, final_estimator), - dash_wrapped=False) - return _VisualBlock('serial', [serial]) + final_block = _VisualBlock('parallel', [final_estimator], + names=['final_estimator'], + dash_wrapped=False) + return _VisualBlock('serial', (parallel, final_block), + dash_wrapped=False) class StackingClassifier(ClassifierMixin, _BaseStacking): From 7ab537d6531ea7340f3314f9a2374301f16c964c Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 26 Feb 2021 09:35:52 -0500 Subject: [PATCH 2/3] DOC Adds comment --- sklearn/ensemble/_stacking.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sklearn/ensemble/_stacking.py b/sklearn/ensemble/_stacking.py index 3fe796a7debd5..4f5800580f8d6 100644 --- a/sklearn/ensemble/_stacking.py +++ b/sklearn/ensemble/_stacking.py @@ -250,6 +250,9 @@ def _sk_visual_block_(self, final_estimator): names, estimators = zip(*self.estimators) parallel = _VisualBlock('parallel', estimators, names=names, dash_wrapped=False) + + # final estimator is wrapped in a parallel block to show the label: + # 'final_estimator' in the html repr final_block = _VisualBlock('parallel', [final_estimator], names=['final_estimator'], dash_wrapped=False) From 2fda9541a917805b87b8233d6f877cfcba2bc2bc Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Fri, 9 Apr 2021 11:18:58 +0200 Subject: [PATCH 3/3] DOC add entry whats new --- doc/whats_new/v1.0.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/whats_new/v1.0.rst b/doc/whats_new/v1.0.rst index 3e36438dda095..e3aa1af70f851 100644 --- a/doc/whats_new/v1.0.rst +++ b/doc/whats_new/v1.0.rst @@ -96,6 +96,10 @@ Changelog target. Additional private refactoring was performed. :pr:`19162` by :user:`Guillaume Lemaitre `. +- |Enhancement| Improve the HTML rendering of the + :class:`ensemble.StackingClassifier` and :class:`ensemble.StackingRegressor`. + :pr:`19564` by `Thomas Fan`_. + :mod:`sklearn.feature_extraction` .................................