Talip7/scikit-learn-issues-multilabel huggingface dataset:
Crying emoticon in "Choosing the right estimator" does not work for most audiences

### Describe the issue linked to the documentation

Contrast https://github.com/scikit-learn/scikit-learn/blob/main/doc/images/ml_map.svg which uses a crying emoticon with previous versions where it said "Not Working" and were easier to understand. 

I teach a brief class on Machine Learning Crying on a weekly basis and have always used "Choosing the right estimator" diagram to illustrate the typical high-level process that a data scientist goes through when picking the best algorithm for their problem, and how it leads to the need of automl and hyperparameter fine tuning. This has always worked well. However, more recently there has been a change where the words "Not working" were replaced by a "crying" emoticon. At first glance, no students in class understand what that means, even younger audiences. I have to magnify it, so they see what it actually is. And when I explain it, they find it awkward. 

### Suggest a potential alternative/fix

Possible solutions:
1) Replace the crying emoticon back with text. It does not have to be "Not Working", it could be something else such as "needs improvement" or
2) Replace the crying emoticon with the Hammer and Wrench emoji: https://emojiguide.org/hammer-and-wrench. Add a legend to the picture stating that it means "not working", "needs improvement", "more work needed". At least this emoji would be more emotionally neutral and would not be perceived as "awkward".
3) At least add a legend explaining that the crying emoticon means "not working", "needs improvement", "more work needed".

COMMENT:
Glad you like it, thanks for your feed-back @clementinodemendonca!

Labels: Documentation
Bad plotly figures rendering in the examples gallery

### Describe the issue linked to the documentation

Currently, I found 2 examples in the examples gallery of the scikit-learn documentation that use plotly instead of matplotlib for plots, for interactivity purposes:
- https://scikit-learn.org/1.5/auto_examples/ensemble/plot_forest_hist_grad_boosting_comparison.html
- https://scikit-learn.org/1.5/auto_examples/model_selection/plot_grid_search_text_feature_extraction.html

[The PyData Sphinx Theme](https://pydata-sphinx-theme.readthedocs.io/), such as the scikit-learn documentation, does not display plotly figures properly. Indeed, plotly figures are cropped and you have to zoom in / out for proper rendering):

https://github.com/user-attachments/assets/ae101e5c-bf24-49aa-8986-7a3fe46ae2fa

This plotly rendering issue appears also in the official [Sphinx doc](https://sphinx-gallery.github.io/stable/auto_plotly_examples/plot_0_plotly.html).

### Suggest a potential alternative/fix

Issues have been opened at
- https://github.com/plotly/Kaleido/issues/210
- https://github.com/sphinx-gallery/sphinx-gallery/issues/1394

Related: https://github.com/plotly/Kaleido/issues/209

COMMENT:
Hopefully this can be fixed in plotly: I think https://github.com/plotly/plotly.py/issues/4828 is the relevant one.

Labels: Documentation
Bad plotly figures rendering in the examples gallery

### Describe the issue linked to the documentation

Currently, I found 2 examples in the examples gallery of the scikit-learn documentation that use plotly instead of matplotlib for plots, for interactivity purposes:
- https://scikit-learn.org/1.5/auto_examples/ensemble/plot_forest_hist_grad_boosting_comparison.html
- https://scikit-learn.org/1.5/auto_examples/model_selection/plot_grid_search_text_feature_extraction.html

[The PyData Sphinx Theme](https://pydata-sphinx-theme.readthedocs.io/), such as the scikit-learn documentation, does not display plotly figures properly. Indeed, plotly figures are cropped and you have to zoom in / out for proper rendering):

https://github.com/user-attachments/assets/ae101e5c-bf24-49aa-8986-7a3fe46ae2fa

This plotly rendering issue appears also in the official [Sphinx doc](https://sphinx-gallery.github.io/stable/auto_plotly_examples/plot_0_plotly.html).

### Suggest a potential alternative/fix

Issues have been opened at
- https://github.com/plotly/Kaleido/issues/210
- https://github.com/sphinx-gallery/sphinx-gallery/issues/1394

Related: https://github.com/plotly/Kaleido/issues/209

COMMENT:
> Hopefully this can be fixed in plotly: I think [plotly/plotly.py#4828](https://github.com/plotly/plotly.py/issues/4828) is the relevant one.

I agree with this, I'm not sure this is a kaleido issue, but just to clarify, there is a new version of kaleido out which requires chrome/chromium to be installed separately.

Labels: Documentation
Bad plotly figures rendering in the examples gallery

### Describe the issue linked to the documentation

Currently, I found 2 examples in the examples gallery of the scikit-learn documentation that use plotly instead of matplotlib for plots, for interactivity purposes:
- https://scikit-learn.org/1.5/auto_examples/ensemble/plot_forest_hist_grad_boosting_comparison.html
- https://scikit-learn.org/1.5/auto_examples/model_selection/plot_grid_search_text_feature_extraction.html

[The PyData Sphinx Theme](https://pydata-sphinx-theme.readthedocs.io/), such as the scikit-learn documentation, does not display plotly figures properly. Indeed, plotly figures are cropped and you have to zoom in / out for proper rendering):

https://github.com/user-attachments/assets/ae101e5c-bf24-49aa-8986-7a3fe46ae2fa

This plotly rendering issue appears also in the official [Sphinx doc](https://sphinx-gallery.github.io/stable/auto_plotly_examples/plot_0_plotly.html).

### Suggest a potential alternative/fix

Issues have been opened at
- https://github.com/plotly/Kaleido/issues/210
- https://github.com/sphinx-gallery/sphinx-gallery/issues/1394

Related: https://github.com/plotly/Kaleido/issues/209

COMMENT:
I implemented a workaround that we could have also in scikit-learn: https://github.com/probabl-ai/skore/pull/748

It seems that there is a side-effect with the secondary sidebar of `pydata-sphinx-theme`.
It seems that the plotly figure get loaded first ignoring the size of the right-hand sidebar (because it is not loaded/toggle yet?).

So the workaround is to make a final resizing of all the plotly figure once the HTML page is ready.

I'm not sure what would be the right fix here because but it might be an interaction between plotly/pydata-sphinx-theme/bootstrap.

And this is where my knowledge in the triptych HTML/CSS/JS is ending :)

Labels: Documentation
ColumnTransformer does not validate sparse formats for X

### Describe the bug

If the underlying transformers all accept sparse input data, `ColumnTransformer` should also be able to accept sparse input data. That's indeed the case for the `csr`, `csc`, `lil` and `dok` formats but it raises errors for the `bsr`, `coo`, `dia` formats because those are not "subscriptable". 

As a possible fix, we could validate sparse input data by using `accept_sparse=("csr", "csc", "lil", "dok")` which will then convert to a "subscriptable" sparse format. Currently it is not done as `ColumnTransformer` relies on its own `_check_X` which often entirely bypasses the validation, maybe for performance reasons ?

### Steps/Code to Reproduce

```python
import numpy as np
from scipy.sparse import dia_array
from sklearn.compose import ColumnTransformer

rng = np.random.RandomState(1)
X = rng.uniform(size=(10, 3))
y = rng.randint(0, 3, size=10)
X = dia_array(X)

est = ColumnTransformer(transformers=[('trans1','passthrough',[0,1])])
est.fit(X, y)
```

### Expected Results

No error is thrown.

### Actual Results

```python-traceback
TypeError: 'dia_array' object is not subscriptable
```

### Versions

```shell
System:
    python: 3.12.5 | packaged by conda-forge | (main, Aug  8 2024, 18:32:50) [Clang 16.0.6 ]
executable: /Users/abaker/miniforge3/envs/sklearn-dev/bin/python
   machine: macOS-14.5-arm64-arm-64bit

Python dependencies:
      sklearn: 1.6.dev0
          pip: 24.2
   setuptools: 73.0.1
        numpy: 2.1.0
        scipy: 1.14.1
       Cython: 3.0.11
       pandas: 2.2.2
   matplotlib: 3.9.2
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libopenblas
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libopenblas.0.dylib
        version: 0.3.27
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: libomp
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libomp.dylib
        version: None
```

COMMENT:
> As a possible fix, we could validate sparse input data by using `accept_sparse=("csr", "csc", "lil", "dok")` which will then convert to a "subscriptable" sparse format.

That seems like a reasonable to me.

> Currently it is not done as `ColumnTransformer` relies on its own `_check_X` which often entirely bypasses the validation, maybe for performance reasons ?

Not sure ...

Labels: Bug
ColumnTransformer does not validate sparse formats for X

### Describe the bug

If the underlying transformers all accept sparse input data, `ColumnTransformer` should also be able to accept sparse input data. That's indeed the case for the `csr`, `csc`, `lil` and `dok` formats but it raises errors for the `bsr`, `coo`, `dia` formats because those are not "subscriptable". 

As a possible fix, we could validate sparse input data by using `accept_sparse=("csr", "csc", "lil", "dok")` which will then convert to a "subscriptable" sparse format. Currently it is not done as `ColumnTransformer` relies on its own `_check_X` which often entirely bypasses the validation, maybe for performance reasons ?

### Steps/Code to Reproduce

```python
import numpy as np
from scipy.sparse import dia_array
from sklearn.compose import ColumnTransformer

rng = np.random.RandomState(1)
X = rng.uniform(size=(10, 3))
y = rng.randint(0, 3, size=10)
X = dia_array(X)

est = ColumnTransformer(transformers=[('trans1','passthrough',[0,1])])
est.fit(X, y)
```

### Expected Results

No error is thrown.

### Actual Results

```python-traceback
TypeError: 'dia_array' object is not subscriptable
```

### Versions

```shell
System:
    python: 3.12.5 | packaged by conda-forge | (main, Aug  8 2024, 18:32:50) [Clang 16.0.6 ]
executable: /Users/abaker/miniforge3/envs/sklearn-dev/bin/python
   machine: macOS-14.5-arm64-arm-64bit

Python dependencies:
      sklearn: 1.6.dev0
          pip: 24.2
   setuptools: 73.0.1
        numpy: 2.1.0
        scipy: 1.14.1
       Cython: 3.0.11
       pandas: 2.2.2
   matplotlib: 3.9.2
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libopenblas
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libopenblas.0.dylib
        version: 0.3.27
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: libomp
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libomp.dylib
        version: None
```

COMMENT:
@antoinebaker i guess there are few option here, add a checking for `DIA format` in your code then :-

1. using `.toarray()`  to convert the DIA format to dense format (not efficient) or,
2. Convert to CSR Format but it adds some computational overhead but its efficient and solves your issue
```
csr_matrix_X = csr_matrix(X)
est = ColumnTransformer(transformers=[('trans1','passthrough',[0,1])])
est.fit(csr_matrix_X, y)
```

Labels: Bug
ColumnTransformer does not validate sparse formats for X

### Describe the bug

If the underlying transformers all accept sparse input data, `ColumnTransformer` should also be able to accept sparse input data. That's indeed the case for the `csr`, `csc`, `lil` and `dok` formats but it raises errors for the `bsr`, `coo`, `dia` formats because those are not "subscriptable". 

As a possible fix, we could validate sparse input data by using `accept_sparse=("csr", "csc", "lil", "dok")` which will then convert to a "subscriptable" sparse format. Currently it is not done as `ColumnTransformer` relies on its own `_check_X` which often entirely bypasses the validation, maybe for performance reasons ?

### Steps/Code to Reproduce

```python
import numpy as np
from scipy.sparse import dia_array
from sklearn.compose import ColumnTransformer

rng = np.random.RandomState(1)
X = rng.uniform(size=(10, 3))
y = rng.randint(0, 3, size=10)
X = dia_array(X)

est = ColumnTransformer(transformers=[('trans1','passthrough',[0,1])])
est.fit(X, y)
```

### Expected Results

No error is thrown.

### Actual Results

```python-traceback
TypeError: 'dia_array' object is not subscriptable
```

### Versions

```shell
System:
    python: 3.12.5 | packaged by conda-forge | (main, Aug  8 2024, 18:32:50) [Clang 16.0.6 ]
executable: /Users/abaker/miniforge3/envs/sklearn-dev/bin/python
   machine: macOS-14.5-arm64-arm-64bit

Python dependencies:
      sklearn: 1.6.dev0
          pip: 24.2
   setuptools: 73.0.1
        numpy: 2.1.0
        scipy: 1.14.1
       Cython: 3.0.11
       pandas: 2.2.2
   matplotlib: 3.9.2
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libopenblas
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libopenblas.0.dylib
        version: 0.3.27
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: libomp
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libomp.dylib
        version: None
```

COMMENT:
> > As a possible fix, we could validate sparse input data by using `accept_sparse=("csr", "csc", "lil", "dok")` which will then convert to a "subscriptable" sparse format.
> 
> That seems like a reasonable to me.
> 
> > Currently it is not done as `ColumnTransformer` relies on its own `_check_X` which often entirely bypasses the validation, maybe for performance reasons ?
> 
> Not sure ...



`_check_X` function in `sklearn/compose/_column_transformer.py`, line 1324:

**Current behavior:**
- Only checks for `sparse.issparse(X)` which returns `True` for `dia_array`(or any other sparse matrix type from `scipy.sparse`).

the best possible fix will be adding a `accept_sparse`

Labels: Bug
ColumnTransformer does not validate sparse formats for X

### Describe the bug

If the underlying transformers all accept sparse input data, `ColumnTransformer` should also be able to accept sparse input data. That's indeed the case for the `csr`, `csc`, `lil` and `dok` formats but it raises errors for the `bsr`, `coo`, `dia` formats because those are not "subscriptable". 

As a possible fix, we could validate sparse input data by using `accept_sparse=("csr", "csc", "lil", "dok")` which will then convert to a "subscriptable" sparse format. Currently it is not done as `ColumnTransformer` relies on its own `_check_X` which often entirely bypasses the validation, maybe for performance reasons ?

### Steps/Code to Reproduce

```python
import numpy as np
from scipy.sparse import dia_array
from sklearn.compose import ColumnTransformer

rng = np.random.RandomState(1)
X = rng.uniform(size=(10, 3))
y = rng.randint(0, 3, size=10)
X = dia_array(X)

est = ColumnTransformer(transformers=[('trans1','passthrough',[0,1])])
est.fit(X, y)
```

### Expected Results

No error is thrown.

### Actual Results

```python-traceback
TypeError: 'dia_array' object is not subscriptable
```

### Versions

```shell
System:
    python: 3.12.5 | packaged by conda-forge | (main, Aug  8 2024, 18:32:50) [Clang 16.0.6 ]
executable: /Users/abaker/miniforge3/envs/sklearn-dev/bin/python
   machine: macOS-14.5-arm64-arm-64bit

Python dependencies:
      sklearn: 1.6.dev0
          pip: 24.2
   setuptools: 73.0.1
        numpy: 2.1.0
        scipy: 1.14.1
       Cython: 3.0.11
       pandas: 2.2.2
   matplotlib: 3.9.2
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libopenblas
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libopenblas.0.dylib
        version: 0.3.27
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: libomp
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libomp.dylib
        version: None
```

COMMENT:
@lesteve i will attempt to fix

Labels: Bug
ColumnTransformer does not validate sparse formats for X

### Describe the bug

If the underlying transformers all accept sparse input data, `ColumnTransformer` should also be able to accept sparse input data. That's indeed the case for the `csr`, `csc`, `lil` and `dok` formats but it raises errors for the `bsr`, `coo`, `dia` formats because those are not "subscriptable". 

As a possible fix, we could validate sparse input data by using `accept_sparse=("csr", "csc", "lil", "dok")` which will then convert to a "subscriptable" sparse format. Currently it is not done as `ColumnTransformer` relies on its own `_check_X` which often entirely bypasses the validation, maybe for performance reasons ?

### Steps/Code to Reproduce

```python
import numpy as np
from scipy.sparse import dia_array
from sklearn.compose import ColumnTransformer

rng = np.random.RandomState(1)
X = rng.uniform(size=(10, 3))
y = rng.randint(0, 3, size=10)
X = dia_array(X)

est = ColumnTransformer(transformers=[('trans1','passthrough',[0,1])])
est.fit(X, y)
```

### Expected Results

No error is thrown.

### Actual Results

```python-traceback
TypeError: 'dia_array' object is not subscriptable
```

### Versions

```shell
System:
    python: 3.12.5 | packaged by conda-forge | (main, Aug  8 2024, 18:32:50) [Clang 16.0.6 ]
executable: /Users/abaker/miniforge3/envs/sklearn-dev/bin/python
   machine: macOS-14.5-arm64-arm-64bit

Python dependencies:
      sklearn: 1.6.dev0
          pip: 24.2
   setuptools: 73.0.1
        numpy: 2.1.0
        scipy: 1.14.1
       Cython: 3.0.11
       pandas: 2.2.2
   matplotlib: 3.9.2
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 8
         prefix: libopenblas
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libopenblas.0.dylib
        version: 0.3.27
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 8
         prefix: libomp
       filepath: /Users/abaker/miniforge3/envs/sklearn-dev/lib/libomp.dylib
        version: None
```

COMMENT:
@lesteve i fixed the changes in this [PR](https://github.com/scikit-learn/scikit-learn/pull/30543) you can review and let me know if anything comes up

Labels: Bug
partial_dependence errors when given only two grid points

### Describe the bug

In the nightly build, when given only two grid points, the partial dependence function incorrectly thinks it is dealing with a binary output and tries to drop one of them in an attempt to fetch only the positive class. The offending line is here: https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/inspection/_partial_dependence.py#L315 This entire check is unneeded because our call to `_get_response_values` above now selects for the positive class in binary models. 

I intend to correct this as part of https://github.com/scikit-learn/scikit-learn/pull/26202, but can split that fix off as well. 

### Steps/Code to Reproduce

```py
from sklearn.dummy import DummyClassifier
from sklearn.inspection import partial_dependence
import numpy as np
import pandas as pd

model = DummyClassifier()
X = pd.DataFrame(
    {
        "a": np.random.randint(0, 10, size=100),
        "b": np.random.randint(0, 10, size=100),
    }
)
y = pd.Series(np.random.randint(0, 2, size=100))
model.fit(X, y)
part_dep = partial_dependence(
    model,
    X,
    features=["a"],
    grid_resolution=2,
    kind="average",
)
```

### Expected Results

No error is thrown and a partial dependence output is computed with two values.

### Actual Results

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/XXXXX/miniconda3/envs/sklearn-test/lib/python3.10/site-packages/sklearn/utils/_param_validation.py", line 216, in wrapper
    return func(*args, **kwargs)
  File "/Users/XXXXX/miniconda3/envs/sklearn-test/lib/python3.10/site-packages/sklearn/inspection/_partial_dependence.py", line 682, in partial_dependence
    averaged_predictions = averaged_predictions.reshape(
ValueError: cannot reshape array of size 1 into shape (2)
```

### Versions

```shell
System:
    python: 3.10.15 | packaged by conda-forge | (main, Oct 16 2024, 01:24:20) [Clang 17.0.6 ]
executable: /Users/XXXX/miniconda3/envs/sklearn-test/bin/python
   machine: macOS-14.7.1-arm64-arm-64bit

Python dependencies:
      sklearn: 1.7.dev0
          pip: 24.3.1
   setuptools: 75.3.0
        numpy: 2.1.3
        scipy: 1.14.1
       Cython: None
       pandas: 2.2.3
   matplotlib: None
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 10
         prefix: libopenblas
       filepath: /Users/XXXX/miniconda3/envs/sklearn-test/lib/libopenblas.0.dylib
        version: 0.3.28
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 10
         prefix: libomp
       filepath: /Users/XXXX/miniconda3/envs/sklearn-test/lib/libomp.dylib
        version: None

       user_api: openmp
   internal_api: openmp
    num_threads: 10
         prefix: libomp
       filepath: /Users/XXXX/miniconda3/envs/sklearn-test/lib/python3.10/site-packages/sklearn/.dylibs/libomp.dylib
        version: None
```

COMMENT:
alright

Labels: Bug