Talip7/scikit-learn-issues-multilabel huggingface dataset:
FEAT Allow the vector-form representation of symetric distance matrices as input

### Describe the workflow you want to enable

I would like to calculate the upper triangle of a distance from `scipy.spatial.distance.pdist` instead of the redundant and memory intensive version from `sklearn.metrics.pairwise_distances` which has $0.5 * (N^2 - N)$ values and use this as input to `metric="precompute"`

### Describe your proposed solution

```python
from scipy.spatial.distance import pdist
X = # Data
dist = pdist(X, metric="jaccard") # Or any other but I just jaccard a lot for my boolean datasets.  Just didn't want to use euclidean/cosine 
clusterer = HDBSCAN(metric="precomputed_triangle")
clusterer.fit(dist)
```

In addition to the original functionality (or ideally replacing):

```python
from scipy.spatial.distance import pdist, squareform
X = # Data
dist = squareform(pdist(X, metric="jaccard")) # Or any other but I just jaccard a lot for my boolean datasets.  Just didn't want to use euclidean/cosine 
clusterer = HDBSCAN(metric="precomputed")
clusterer.fit(dist)
```

### Describe alternatives you've considered, if relevant

Using the redundant square form but this requires a lot more memory that isn't necessary. 

### Additional context

It may be worthwhile creating a `DistanceMatrix` object like https://scikit.bio/docs/latest/generated/skbio.stats.distance.DistanceMatrix.html#skbio.stats.distance.DistanceMatrix

COMMENT:
Would it make sense to force full distance matrices (ie redundant and square) into non-redundant vector form? To lower the memory footprint overall or to allow full distances if provided to increase performance at the cost of memory?

Labels: New Feature, Performance, help wanted, Hard
FEAT Allow the vector-form representation of symetric distance matrices as input

### Describe the workflow you want to enable

I would like to calculate the upper triangle of a distance from `scipy.spatial.distance.pdist` instead of the redundant and memory intensive version from `sklearn.metrics.pairwise_distances` which has $0.5 * (N^2 - N)$ values and use this as input to `metric="precompute"`

### Describe your proposed solution

```python
from scipy.spatial.distance import pdist
X = # Data
dist = pdist(X, metric="jaccard") # Or any other but I just jaccard a lot for my boolean datasets.  Just didn't want to use euclidean/cosine 
clusterer = HDBSCAN(metric="precomputed_triangle")
clusterer.fit(dist)
```

In addition to the original functionality (or ideally replacing):

```python
from scipy.spatial.distance import pdist, squareform
X = # Data
dist = squareform(pdist(X, metric="jaccard")) # Or any other but I just jaccard a lot for my boolean datasets.  Just didn't want to use euclidean/cosine 
clusterer = HDBSCAN(metric="precomputed")
clusterer.fit(dist)
```

### Describe alternatives you've considered, if relevant

Using the redundant square form but this requires a lot more memory that isn't necessary. 

### Additional context

It may be worthwhile creating a `DistanceMatrix` object like https://scikit.bio/docs/latest/generated/skbio.stats.distance.DistanceMatrix.html#skbio.stats.distance.DistanceMatrix

COMMENT:
I don't think we'd want to force the vector form. Most usecases don't mind the memory footprint.

Labels: New Feature, Performance, help wanted, Hard
FEAT Allow the vector-form representation of symetric distance matrices as input

### Describe the workflow you want to enable

I would like to calculate the upper triangle of a distance from `scipy.spatial.distance.pdist` instead of the redundant and memory intensive version from `sklearn.metrics.pairwise_distances` which has $0.5 * (N^2 - N)$ values and use this as input to `metric="precompute"`

### Describe your proposed solution

```python
from scipy.spatial.distance import pdist
X = # Data
dist = pdist(X, metric="jaccard") # Or any other but I just jaccard a lot for my boolean datasets.  Just didn't want to use euclidean/cosine 
clusterer = HDBSCAN(metric="precomputed_triangle")
clusterer.fit(dist)
```

In addition to the original functionality (or ideally replacing):

```python
from scipy.spatial.distance import pdist, squareform
X = # Data
dist = squareform(pdist(X, metric="jaccard")) # Or any other but I just jaccard a lot for my boolean datasets.  Just didn't want to use euclidean/cosine 
clusterer = HDBSCAN(metric="precomputed")
clusterer.fit(dist)
```

### Describe alternatives you've considered, if relevant

Using the redundant square form but this requires a lot more memory that isn't necessary. 

### Additional context

It may be worthwhile creating a `DistanceMatrix` object like https://scikit.bio/docs/latest/generated/skbio.stats.distance.DistanceMatrix.html#skbio.stats.distance.DistanceMatrix

COMMENT:
Also, most use cases do not have a symmetric distance matrix as well as generally `X_train != X_test`

Labels: New Feature, Performance, help wanted, Hard
Pre-Built Dataset-Specific Pipelines for scikit-learn/ML Beginners

### Describe the workflow you want to enable

I would be fine allowing anyone else to contribute along with this series of pre-built pipelines or simply being the first to make one for one of the already included datasets in scikit-learn.

### Describe your proposed solution

I think that a series of already built pipelines with some basic preprocessing and other steps should be made available for those that are new scikit-learn or machine learning in general.  Essentially, some example pipelines will be created and tuned for various datasets that scikit-learn already offers. These should be easily downloadable through some mean, maybe as pickle files so that newcomers can instantly deploy simple models on common datasets.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Having already built pipelines would allow newcomers to easily deploy them and see the results that well-crafted learning models can have. This would hopefully minimize the amount of discouraged individuals who find the starting learning curve of developing machine learning models difficult and encourage them to continue their path.

COMMENT:
I don't think that the proposal here can be either in the documentation of scikit-learn or in the repository. Probably such pre-built pipeline would have its home on OpenML (https://www.openml.org/) or HuggingFace (https://huggingface.co)

Labels: New Feature, Needs Triage
Request to update "Choosing the Right Estimator" Graphic (scikit-learn algorithm cheat sheet)

### Describe the issue linked to the documentation

As in the documented map here - https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html

The path after `Predicting a category` (When "YES") goes to both classification & Regression.

Also, Path after answering `Predicting a quantity` goes to only one direction (Missing path to regression).

![Issue](https://github.com/scikit-learn/scikit-learn/assets/60871161/e227afb9-1b44-428b-91c5-419d52d4c98f)


### Suggest a potential alternative/fix


#### It seems to be a `SVG` mistake, please change or update it accordingly

COMMENT:
I just wanted to create a similar issue, as I found this graphic (in an older version) [here](https://github.com/microsoft/ML-For-Beginners/blob/main/4-Classification/3-Classifiers-2/README.md). In this version, the arrows are correct.

Labels: Bug, Documentation
Request to update "Choosing the Right Estimator" Graphic (scikit-learn algorithm cheat sheet)

### Describe the issue linked to the documentation

As in the documented map here - https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html

The path after `Predicting a category` (When "YES") goes to both classification & Regression.

Also, Path after answering `Predicting a quantity` goes to only one direction (Missing path to regression).

![Issue](https://github.com/scikit-learn/scikit-learn/assets/60871161/e227afb9-1b44-428b-91c5-419d52d4c98f)


### Suggest a potential alternative/fix


#### It seems to be a `SVG` mistake, please change or update it accordingly

COMMENT:
This is a duplicated issue: #28314.

I'm going to close and I propose you to comment on this issue to centralize all the comments.

Labels: Bug, Documentation
Request to update "Choosing the Right Estimator" Graphic (scikit-learn algorithm cheat sheet)

### Describe the issue linked to the documentation

As in the documented map here - https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html

The path after `Predicting a category` (When "YES") goes to both classification & Regression.

Also, Path after answering `Predicting a quantity` goes to only one direction (Missing path to regression).

![Issue](https://github.com/scikit-learn/scikit-learn/assets/60871161/e227afb9-1b44-428b-91c5-419d52d4c98f)


### Suggest a potential alternative/fix


#### It seems to be a `SVG` mistake, please change or update it accordingly

COMMENT:
I saw that, but that issue was specific to another change,
still changing the graphic will solve everything!

OK, now i'll follow #28314 regarding this!

Labels: Bug, Documentation
Request to update "Choosing the Right Estimator" Graphic (scikit-learn algorithm cheat sheet)

### Describe the issue linked to the documentation

As in the documented map here - https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html

The path after `Predicting a category` (When "YES") goes to both classification & Regression.

Also, Path after answering `Predicting a quantity` goes to only one direction (Missing path to regression).

![Issue](https://github.com/scikit-learn/scikit-learn/assets/60871161/e227afb9-1b44-428b-91c5-419d52d4c98f)


### Suggest a potential alternative/fix


#### It seems to be a `SVG` mistake, please change or update it accordingly

COMMENT:
> I saw that, but that issue was specific to another change,
still changing the graphic will solve everything!

We can welcome additional thoughts or issue regarding the graphic to consolidate it. So if even this is a bit different, I think this would be the right place to comment ;)

Labels: Bug, Documentation
Request to update "Choosing the Right Estimator" Graphic (scikit-learn algorithm cheat sheet)

### Describe the issue linked to the documentation

As in the documented map here - https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html

The path after `Predicting a category` (When "YES") goes to both classification & Regression.

Also, Path after answering `Predicting a quantity` goes to only one direction (Missing path to regression).

![Issue](https://github.com/scikit-learn/scikit-learn/assets/60871161/e227afb9-1b44-428b-91c5-419d52d4c98f)


### Suggest a potential alternative/fix


#### It seems to be a `SVG` mistake, please change or update it accordingly

COMMENT:
@glemaitre I think it's a valid and different issue than the one you mention. There's a regression in the map from the new web theme. I guess there was a mistake when migrating the svg. The "predicting a category" node is not correct anymore (see the previous version https://scikit-learn.org/1.4/tutorial/machine_learning_map/index.html)

Labels: Bug, Documentation
Request to update "Choosing the Right Estimator" Graphic (scikit-learn algorithm cheat sheet)

### Describe the issue linked to the documentation

As in the documented map here - https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html

The path after `Predicting a category` (When "YES") goes to both classification & Regression.

Also, Path after answering `Predicting a quantity` goes to only one direction (Missing path to regression).

![Issue](https://github.com/scikit-learn/scikit-learn/assets/60871161/e227afb9-1b44-428b-91c5-419d52d4c98f)


### Suggest a potential alternative/fix


#### It seems to be a `SVG` mistake, please change or update it accordingly

COMMENT:
I see, I overlooked. Yep, the SVG has probably been remade to adapt for dark and light themes and the error has been introduced.

Labels: Bug, Documentation
Request to update "Choosing the Right Estimator" Graphic (scikit-learn algorithm cheat sheet)

### Describe the issue linked to the documentation

As in the documented map here - https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html

The path after `Predicting a category` (When "YES") goes to both classification & Regression.

Also, Path after answering `Predicting a quantity` goes to only one direction (Missing path to regression).

![Issue](https://github.com/scikit-learn/scikit-learn/assets/60871161/e227afb9-1b44-428b-91c5-419d52d4c98f)


### Suggest a potential alternative/fix


#### It seems to be a `SVG` mistake, please change or update it accordingly

COMMENT:
Thanks @jeremiedbb, I recently started contributing like this, and I'm quite happy that it's a valid Issue 😃

Labels: Bug, Documentation
Request to update "Choosing the Right Estimator" Graphic (scikit-learn algorithm cheat sheet)

### Describe the issue linked to the documentation

As in the documented map here - https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html

The path after `Predicting a category` (When "YES") goes to both classification & Regression.

Also, Path after answering `Predicting a quantity` goes to only one direction (Missing path to regression).

![Issue](https://github.com/scikit-learn/scikit-learn/assets/60871161/e227afb9-1b44-428b-91c5-419d52d4c98f)


### Suggest a potential alternative/fix


#### It seems to be a `SVG` mistake, please change or update it accordingly

COMMENT:
My bad here, this is indeed a mistake during migration. Will make a PR to fix soon.

Labels: Bug, Documentation
ColumnTransformer ignores certain column t

### Describe the bug

I have a series of fitted CountVectorizers each will preprocess a column of the dataframe. However when putting them in ColumnTransformer, a few CountVecrotizers were given the whole dataframe rather than just the column it is supposed to process.

### Steps/Code to Reproduce

```
# Fit each column individually as the number of rows is huge
cvs = {i: CountVectorizer().fit(spark_df[i].toPandas()[i]) for i in spark_df.columns}
ct = ColumnTransformer([(i, cvs[i] ,i) for i in spark_df.columns])
ct.transform(spark_df.limit(5).toPandas())
```
It will got an error:
`ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 168551 and the array at index 148 has size 2`

The reason is that ct.transformers[148] was given a dataframe rather than a series. Any idea why only 148 is seeing this issue? Shouldn't ct treats all countvectorizers indifferently?


If I sequentially run the countvectorizers:
```
for n, i in enumerate(ct.transformers):
    print(n, i[2], i[1].transform(spark_df.limit(5).toPandas()[i[2]]).shape)
```
It will work as I have explicitly enforced each input to the countvectorizer is a pd.Series.


### Expected Results

ColumnTransformer sends only the required column as pd.Series to each countvectorizer.

### Actual Results

Error, ct.transformers[148] is thrown in the whole dataframe rather than the column as a pd.Series

### Versions

```shell
1.4.2
```

COMMENT:
Could you provide a minimal reproducer that we can locally execute to debug and fix the potential bug?

Labels: Bug, Needs Info
ColumnTransformer ignores certain column t

### Describe the bug

I have a series of fitted CountVectorizers each will preprocess a column of the dataframe. However when putting them in ColumnTransformer, a few CountVecrotizers were given the whole dataframe rather than just the column it is supposed to process.

### Steps/Code to Reproduce

```
# Fit each column individually as the number of rows is huge
cvs = {i: CountVectorizer().fit(spark_df[i].toPandas()[i]) for i in spark_df.columns}
ct = ColumnTransformer([(i, cvs[i] ,i) for i in spark_df.columns])
ct.transform(spark_df.limit(5).toPandas())
```
It will got an error:
`ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 168551 and the array at index 148 has size 2`

The reason is that ct.transformers[148] was given a dataframe rather than a series. Any idea why only 148 is seeing this issue? Shouldn't ct treats all countvectorizers indifferently?


If I sequentially run the countvectorizers:
```
for n, i in enumerate(ct.transformers):
    print(n, i[2], i[1].transform(spark_df.limit(5).toPandas()[i[2]]).shape)
```
It will work as I have explicitly enforced each input to the countvectorizer is a pd.Series.


### Expected Results

ColumnTransformer sends only the required column as pd.Series to each countvectorizer.

### Actual Results

Error, ct.transformers[148] is thrown in the whole dataframe rather than the column as a pd.Series

### Versions

```shell
1.4.2
```

COMMENT:
Unfortunately the data is private so can't be shared. I've found the workaround of https://github.com/scikit-learn/scikit-learn/issues/28928 works well so closing this one.

Labels: Bug, Needs Info
Incorrect invalid device error introduced in #25956

### Describe the bug

#25956 introduced a new `sklearn.utils._array_api._check_device_cpu` function to test whether a tensor is on CPU. However, the implementation of the test, which is `device not in {"cpu", None}`, is incorrect -- the device will actually not be a string, but `device(type='cpu')`. Therefore, you should attempt to get the `type` attr, and use that if available.

### Steps/Code to Reproduce

You can view a sample error here:
https://github.com/fastai/fastai/actions/runs/9232979440/job/25404873935

### Expected Results

`ValueError: Unsupported device for NumPy: device(type='cpu')`  should not be thrown.

### Actual Results

```
File /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/sklearn/utils/_array_api.py:308, in _check_device_cpu(device)
    306 def _check_device_cpu(device):  # noqa
    307     if device not in {"cpu", None}:
--> 308         raise ValueError(f"Unsupported device for NumPy: {device!r}")

ValueError: Unsupported device for NumPy: device(type='cpu')
```

### Versions

```shell
I've seen this on multiple Linux and Mac versions. My current Mac version:


System:
    python: 3.11.8 (main, Feb 26 2024, 15:36:12) [Clang 14.0.6 ]
executable: /Users/jhoward/miniconda3/bin/python
   machine: macOS-14.3.1-arm64-arm-64bit

Python dependencies:
      sklearn: 1.4.2
          pip: 23.3.1
   setuptools: 68.2.2
        numpy: 1.26.4
        scipy: 1.13.0
       Cython: None
       pandas: 2.2.1
   matplotlib: 3.8.4
       joblib: 1.4.0
threadpoolctl: 2.2.0

Built with OpenMP: True

threadpoolctl info:
       filepath: /Users/jhoward/miniconda3/lib/libopenblasp-r0.3.21.dylib
         prefix: libopenblas
       user_api: blas
   internal_api: openblas
        version: 0.3.21
    num_threads: 8
threading_layer: pthreads
   architecture: armv8

       filepath: /Users/jhoward/miniconda3/lib/libomp.dylib
         prefix: libomp
       user_api: openmp
   internal_api: openmp
        version: None
    num_threads: 8
```
```

COMMENT:
Do you have a minimal reproducer.

Looking at our code, I think that we expect to have a call to the `sklearn.utils._array_api.device` that is going to return the string `"cpu"`. So it would be interesting to understand what is generating the `device` object to have a proper regression test.

I'm not the most familiar with the array API work so, ping @betatim and @ogrisel.

Labels: Bug, Regression, Array API
Incorrect invalid device error introduced in #25956

### Describe the bug

#25956 introduced a new `sklearn.utils._array_api._check_device_cpu` function to test whether a tensor is on CPU. However, the implementation of the test, which is `device not in {"cpu", None}`, is incorrect -- the device will actually not be a string, but `device(type='cpu')`. Therefore, you should attempt to get the `type` attr, and use that if available.

### Steps/Code to Reproduce

You can view a sample error here:
https://github.com/fastai/fastai/actions/runs/9232979440/job/25404873935

### Expected Results

`ValueError: Unsupported device for NumPy: device(type='cpu')`  should not be thrown.

### Actual Results

```
File /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/sklearn/utils/_array_api.py:308, in _check_device_cpu(device)
    306 def _check_device_cpu(device):  # noqa
    307     if device not in {"cpu", None}:
--> 308         raise ValueError(f"Unsupported device for NumPy: {device!r}")

ValueError: Unsupported device for NumPy: device(type='cpu')
```

### Versions

```shell
I've seen this on multiple Linux and Mac versions. My current Mac version:


System:
    python: 3.11.8 (main, Feb 26 2024, 15:36:12) [Clang 14.0.6 ]
executable: /Users/jhoward/miniconda3/bin/python
   machine: macOS-14.3.1-arm64-arm-64bit

Python dependencies:
      sklearn: 1.4.2
          pip: 23.3.1
   setuptools: 68.2.2
        numpy: 1.26.4
        scipy: 1.13.0
       Cython: None
       pandas: 2.2.1
   matplotlib: 3.8.4
       joblib: 1.4.0
threadpoolctl: 2.2.0

Built with OpenMP: True

threadpoolctl info:
       filepath: /Users/jhoward/miniconda3/lib/libopenblasp-r0.3.21.dylib
         prefix: libopenblas
       user_api: blas
   internal_api: openblas
        version: 0.3.21
    num_threads: 8
threading_layer: pthreads
   architecture: armv8

       filepath: /Users/jhoward/miniconda3/lib/libomp.dylib
         prefix: libomp
       user_api: openmp
   internal_api: openmp
        version: None
    num_threads: 8
```
```

COMMENT:
Looking at the code, this function `_check_device_cpu` seems to only be used for `_NumPyAPIWrapper` which is not meant to be called in torch inputs I think. So we need to understand how you ended up with an `xp` module that is an instance of the `_NumPyAPIWrapper` but with a `device` variable that holds a torch device (instead of `None`).

Labels: Bug, Regression, Array API