Unexpected behavior of the HTML repr of meta-estimators

Here's a list of some unexpected behaviors of the HTML repr of meta-estimators
- `Pipeline` doesn't display its named steps

  <img width="164" height="95" alt="Image" src="https://github.com/user-attachments/assets/c368188d-544f-4bb1-bfeb-d76490f5146a" />

  This was maybe intentional ? In comparison `FeatureUnion` does for instance

  <img width="282" height="91" alt="Image" src="https://github.com/user-attachments/assets/2a6ded8c-d148-4852-a03c-0a88c1b8bc49" />

- a `Pipeline` in a meta-estimator doesn't render properly; it doesn't have the dashed border
  
  <img width="186" height="120" alt="Image" src="https://github.com/user-attachments/assets/471ce468-8597-4fbc-b718-870c4f11a1fd" />

  Another meta-estimator renders properly

  <img width="294" height="116" alt="Image" src="https://github.com/user-attachments/assets/cb467dcd-63c2-4a54-b92a-d6686b3b3bc8" />

- transformers of `ColumnTransformer` are expandable to show the selected columns, but there's no additional info. I think it should be explicit that these are the selected columns.

  <img width="274" height="106" alt="Image" src="https://github.com/user-attachments/assets/e44d47fb-c784-4631-9a73-3d274671430e" />

  Note that this could be fixed by https://github.com/scikit-learn/scikit-learn/pull/31937

- When the inner estimator of a meta-estimator is not a meta-estimator itself, it's expandable but the dropdown is not useful anymore (it's the non-html repr of the estimator basically):

  <img width="169" height="129" alt="Image" src="https://github.com/user-attachments/assets/21723076-ae7e-46e3-8d22-3561aef1b1ec" />

  Now that we have the parameter table, it's not useful anymore to have the additional repr which is redundant and less informative. I'd be in favor of removing the dropdown

- When the inner estimator of a meta-estimator is a meta-estimator itself, it's expandable but sometimes there's no dropdown or the dropdown is the non-html repr of the meta-estimator, and there's no parameter table.

  <img width="178" height="121" alt="Image" src="https://github.com/user-attachments/assets/4fbdb1fa-8f5e-4d32-9bd2-56bc4e89d891" />

  <img width="392" height="143" alt="Image" src="https://github.com/user-attachments/assets/1294de22-afcb-49c3-9256-b0cda06f352a" />

  I think that it should display the parameter table instead in both cases

COMMENT:
Numbering Jérémie's original list:

1. >Pipeline doesn't display its named steps. This was maybe intentional ? In comparison
FeatureUnion does for instance.

I'm finding that it displays the names when it wraps more components. It seems that on the original PR that added the HTML display to scikit-learn, it was on purpose to remove cluttering. But I need to investigate more to see if it can be improved. 

Anyway,  with this example, the Pipeline that wraps all the components has the named steps:
<details><summary>Code to generate the diagram</summary>

from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.linear_model import LogisticRegression
from sklearn.decomposition import PCA, TruncatedSVD
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import GaussianNB
from sklearn.ensemble import RandomForestClassifier, VotingClassifier
from sklearn.pipeline import FeatureUnion
from sklearn.feature_selection import SelectPercentile
#from sklearn.inspection import display_estimator

numeric_transformer = Pipeline(steps=[
('imputer', SimpleImputer(strategy='median'))])

feat_u2 = FeatureUnion([("pca", PCA(n_components=1)),
("svd", Pipeline([('tsvd1', TruncatedSVD(n_components=2)),
('select', SelectPercentile())]))])

numeric_features = ["test", "test2"]
numeric_transformer2 = Pipeline(steps=[
('imputer', SimpleImputer(strategy='most_frequent')),
('scaler', StandardScaler(with_std=False)),
('feats', feat_u2)
])
categorical_features = ['embarked', 'sex', 'pclass']
categorical_transformer = Pipeline(steps=[
('imputer', SimpleImputer(strategy='constant', missing_values="missing")),
('onehot', OneHotEncoder(handle_unknown='ignore', drop='first'))])

preprocessor = ColumnTransformer(
transformers=[
('num1', numeric_transformer, numeric_features),
('num2', numeric_transformer2, numeric_features),
('cat', categorical_transformer, categorical_features)])

feat_u = FeatureUnion([("pca", PCA(n_components=1, whiten=True, svd_solver='full')),
("svd", TruncatedSVD(n_components=2, n_iter=10))])
clf1 = LogisticRegression(solver='lbfgs',
random_state=1, max_iter=200)
clf2 = RandomForestClassifier(n_estimators=50, random_state=1, max_depth=8, warm_start=True, n_jobs=3, oob_score=True)
clf3 = GaussianNB()
eclf1 = VotingClassifier(estimators=[
('lr', clf1), ('rf', clf2), ('gnb', clf3)], voting='hard')

clf = Pipeline(steps=[('preprocessor', preprocessor),
('feat_u', feat_u),
('classifier', eclf1)])

clf

</details> 

<img width="500" height="240" alt="Image" src="https://github.com/user-attachments/assets/42b8b3b6-6142-4487-b092-a3af4b197860" />
<br>
<br>

----
2. >A Pipeline in a meta-estimator doesn't render properly; it doesn't have the dashed
border.

      If we add the dashed border to pipelines, it fixes the example in the issue. 

      <img width="200" height="100" alt="Image" src="https://github.com/user-attachments/assets/493d1920-eeb8-4b03-8f57-29c65357a245" />

     But also adds to num1, num2 and cat:
     <img width="500" height="200" alt="Image" src="https://github.com/user-attachments/assets/1a383e0a-c232-4a6d-a19b-f7447640446c" />

    So, I guess more logic can be added before we do [`dash_wrapped=False`](https://github.com/scikit-learn/scikit-learn/blob/306a55eb6fba5f34062a21c59a8a1900cdeb7eaa/sklearn/pipeline.py#L1275). I wonder if that's what we want.

----
3. >Transformers of ColumnTransformer are expandable to show the selected columns,
but there's no additional info. I think it should be explicit that these are the selected
columns.
Note that this could be fixed by https://github.com/scikit-learn/scikit-learn/pull/31937

-----
4. >When the inner estimator of a meta-estimator is not a meta-estimator itself, it's
expandable but the dropdown is not useful anymore (it's the non-html repr of the
estimator basically):
Now that we have the parameter table, it's not useful anymore to have the additional
repr which is redundant and less informative. I'd be in favor of removing the dropdown.

I think that the reason is that `name` in `_write_label_html`, can be information about the ColumnTransformer, or the name of the estimator. Maybe an extra variable could be added so we split its usage, or we need to add more logic to differentiate them. 
https://github.com/scikit-learn/scikit-learn/blob/306a55eb6fba5f34062a21c59a8a1900cdeb7eaa/sklearn/utils/_repr_html/estimator.py#L133


-----
5. >When the inner estimator of a meta-estimator is a meta-estimator itself, it's
expandable but sometimes there's no dropdown or the dropdown is the non-html repr
of the meta-estimator, and there's no parameter table.
I think that it should display the parameter table instead in both cases.

I think that this is not a bug, but that it has not been implemented. I say this because `TransformedTargetRegressor` doesn't have a `_sk_visual_block` like Pipelines or Column transformers.

Labels: Documentation, frontend