Talip7/scikit-learn-issues-multilabel huggingface dataset:
NearestCentroid not handling properly distance metrics other than Manhattan or Euclidean.

### Describe the bug

Three issues, quite related.

* Using a metric that is not Manhattan or Euclidean triggers the following warning: `UserWarning: Averaging for metrics other than euclidean and manhattan not supported. The average is set to be the mean.`, but I believe an error message should be thrown instead. Indeed, computing the centroids as the average of the class samples is wrong for (I think) all distances except Euclidean, so it is misleading to actually do it even with a warning. Throwing an error here would fix the 2 following issues.

* Calling `.predict` on a `NearestCentroid` with metric `wminkowski`, `seuclidean` or `mahalanobis` throws an error, because those metrics need params that we can't pass to `NearestCentroid`. #23806 would fix the documentation, but maybe it should be nice to handle this properly in the code.

* Using any string as a `metric` (even a random string like `foobar`) does not throws an error when fitting, but does when calling `.predict`. Doing this with another classifier like `KNeighborsClassifier` throws an error at the fitting step.

If relevant I'd like to work on fixing those issues (new contributor here :)) I noticed a stalled PR (#19262) related to implementing `partial_fit` to `NearestCentroid`. Maybe I should start working on it first, as it seems to improve the code quality of `_nearest_centroid.py`, so it would be an interesting base to start with.

### Steps/Code to Reproduce

```python
#Reproduces the second issue mentionned

from sklearn.neighbors import NearestCentroid
from sklearn.datasets import load_iris
iris = load_iris()
X = iris.data
y = iris.target
nearest_centroid = NearestCentroid(metric="seuclidean")
nearest_centroid.fit(X,y)
nearest_centroid.predict(X)
```

### Expected Results

Fitting a `NearestCentroid` with a metric that is not Manhattan or Euclidean should trigger a proper error message.

### Actual Results

Error related to the second issue:
`ValueError: The 'V' parameter is required for the seuclidean metric when Y is passed.`

### Versions

```shell
System:
    python: 3.8.6 (default, Mar 29 2021, 18:42:37)  [Clang 12.0.0 (clang-1200.0.32.29)]
executable: /Users/valentinlaurent/.pyenv/versions/3.8.6/envs/lewagon/bin/python3.8
   machine: macOS-10.15.7-x86_64-i386-64bit

Python dependencies:
          pip: 22.1.1
   setuptools: 49.2.1
      sklearn: 1.0.2
        numpy: 1.19.5
        scipy: 1.6.2
       Cython: 0.29.26
       pandas: 1.1.3
   matplotlib: 3.4.1
       joblib: 1.1.0
threadpoolctl: 2.1.0

Built with OpenMP: True
```

COMMENT:
It seems that this issue can be closed? @ogrisel

Labels: Bug, module:neighbors
NearestCentroid not handling properly distance metrics other than Manhattan or Euclidean.

### Describe the bug

Three issues, quite related.

* Using a metric that is not Manhattan or Euclidean triggers the following warning: `UserWarning: Averaging for metrics other than euclidean and manhattan not supported. The average is set to be the mean.`, but I believe an error message should be thrown instead. Indeed, computing the centroids as the average of the class samples is wrong for (I think) all distances except Euclidean, so it is misleading to actually do it even with a warning. Throwing an error here would fix the 2 following issues.

* Calling `.predict` on a `NearestCentroid` with metric `wminkowski`, `seuclidean` or `mahalanobis` throws an error, because those metrics need params that we can't pass to `NearestCentroid`. #23806 would fix the documentation, but maybe it should be nice to handle this properly in the code.

* Using any string as a `metric` (even a random string like `foobar`) does not throws an error when fitting, but does when calling `.predict`. Doing this with another classifier like `KNeighborsClassifier` throws an error at the fitting step.

If relevant I'd like to work on fixing those issues (new contributor here :)) I noticed a stalled PR (#19262) related to implementing `partial_fit` to `NearestCentroid`. Maybe I should start working on it first, as it seems to improve the code quality of `_nearest_centroid.py`, so it would be an interesting base to start with.

### Steps/Code to Reproduce

```python
#Reproduces the second issue mentionned

from sklearn.neighbors import NearestCentroid
from sklearn.datasets import load_iris
iris = load_iris()
X = iris.data
y = iris.target
nearest_centroid = NearestCentroid(metric="seuclidean")
nearest_centroid.fit(X,y)
nearest_centroid.predict(X)
```

### Expected Results

Fitting a `NearestCentroid` with a metric that is not Manhattan or Euclidean should trigger a proper error message.

### Actual Results

Error related to the second issue:
`ValueError: The 'V' parameter is required for the seuclidean metric when Y is passed.`

### Versions

```shell
System:
    python: 3.8.6 (default, Mar 29 2021, 18:42:37)  [Clang 12.0.0 (clang-1200.0.32.29)]
executable: /Users/valentinlaurent/.pyenv/versions/3.8.6/envs/lewagon/bin/python3.8
   machine: macOS-10.15.7-x86_64-i386-64bit

Python dependencies:
          pip: 22.1.1
   setuptools: 49.2.1
      sklearn: 1.0.2
        numpy: 1.19.5
        scipy: 1.6.2
       Cython: 0.29.26
       pandas: 1.1.3
   matplotlib: 3.4.1
       joblib: 1.1.0
threadpoolctl: 2.1.0

Built with OpenMP: True
```

COMMENT:
Indeed, fixed by #24083. Let's close

Labels: Bug, module:neighbors
Different inertia values even with random_state set

### Describe the bug

Im trying to make my algorithm, which involves KMeans, reproducible, but even If I set random_state value I always get different inertia values. 
I'm using this [page](https://github.com/danielgribel/hg-means/blob/master/data/page.txt) dataset without the first line (dataset size).

### Steps/Code to Reproduce

```
from sklearn.cluster import KMeans
import numpy as np

points = np.genfromtxt('page.txt')
for l in range(10):
    kmeans = KMeans(n_clusters=30, n_init=1, random_state=42)
    kmeans.fit(points)

    centroids = kmeans.cluster_centers_
    print('{0:.20f}'.format(kmeans.inertia_))
```

### Expected Results

I expect to get printed ten time the same value

### Actual Results

1008436173.14048004150390625000
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14048004150390625000
1008436173.14048004150390625000

### Versions

```shell
System:
    python: 3.9.12 (v3.9.12:b28265d7e6, Mar 23 2022, 18:22:40)  [Clang 13.0.0 (clang-1300.0.29.30)]
executable: /Users/user/PycharmProjects/MDE/venv/bin/python
   machine: macOS-12.4-arm64-arm-64bit
Python dependencies:
      sklearn: 1.1.0
          pip: 21.3.1
   setuptools: 60.2.0
        numpy: 1.22.4
        scipy: 1.8.0
       Cython: None
       pandas: 1.4.2
   matplotlib: 3.5.2
       joblib: 1.1.0
threadpoolctl: 3.1.0
Built with OpenMP: True
```

COMMENT:
ping @jeremiedbb

Labels: module:cluster
Different inertia values even with random_state set

### Describe the bug

Im trying to make my algorithm, which involves KMeans, reproducible, but even If I set random_state value I always get different inertia values. 
I'm using this [page](https://github.com/danielgribel/hg-means/blob/master/data/page.txt) dataset without the first line (dataset size).

### Steps/Code to Reproduce

```
from sklearn.cluster import KMeans
import numpy as np

points = np.genfromtxt('page.txt')
for l in range(10):
    kmeans = KMeans(n_clusters=30, n_init=1, random_state=42)
    kmeans.fit(points)

    centroids = kmeans.cluster_centers_
    print('{0:.20f}'.format(kmeans.inertia_))
```

### Expected Results

I expect to get printed ten time the same value

### Actual Results

1008436173.14048004150390625000
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14047992229461669922
1008436173.14048004150390625000
1008436173.14048004150390625000
1008436173.14048004150390625000

### Versions

```shell
System:
    python: 3.9.12 (v3.9.12:b28265d7e6, Mar 23 2022, 18:22:40)  [Clang 13.0.0 (clang-1300.0.29.30)]
executable: /Users/user/PycharmProjects/MDE/venv/bin/python
   machine: macOS-12.4-arm64-arm-64bit
Python dependencies:
      sklearn: 1.1.0
          pip: 21.3.1
   setuptools: 60.2.0
        numpy: 1.22.4
        scipy: 1.8.0
       Cython: None
       pandas: 1.4.2
   matplotlib: 3.5.2
       joblib: 1.1.0
threadpoolctl: 3.1.0
Built with OpenMP: True
```

COMMENT:
The relative difference between these inertiae is less than machine precision (~2e-16). It may be due to rounding errors being different due to the multi-threaded aspect of inertia computation. However, the clustering should be the same, i.e. centers and labels should be the same. I checked with your example on my machine and it's the case.

Labels: module:cluster
TfidfVectorizer Argument "Input" Overrides Python Keyword

### Describe the bug

The first argument for the TfidfVectorizer class is named `input` (shown on the documentation page [here](https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html)), but this is already the name of a Python keyword. When passing this argument into the class it will be highlighted indicating it is already a Python keyword.

This has the potential to cause unintended overrides and should be changed to better follow naming conventions. PEP8 [convention](https://peps.python.org/pep-0008/#overriding-principle) is to add a trailing underscore to avoid overrides (e.g. "input_"), but because this variable is a string descriptor it would be more user intuitive to change it to something like "input_type".

### Steps/Code to Reproduce

```python
# argument 'input' will be highlighted
# showing it is already a Python keyword
TfidfVectorizer(input = "filename")
```

### Expected Results

```python
# with a different name, the argument will not longer be highlighted. 
# This shows it is no longer overriding a Python keyword.
TfidfVectorizer(input_type = "filename")
```

### Actual Results

```python
# Actual results are identical to the MRE
# since this Issue is meant to address potential override
TfidfVectorizer(input = "filename")
```

### Versions

```shell
System:
    python: 3.9.5

Python dependencies:
          pip: 21.1.3
   setuptools: 52.0.0.post20210125
      sklearn: 1.0.2
        numpy: 1.21.2
        scipy: 1.7.3
       Cython: None
       pandas: 1.3.5
   matplotlib: 3.5.0
       joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True
```

COMMENT:
I am closing this issue with the reason stated in https://github.com/scikit-learn/scikit-learn/pull/23881#pullrequestreview-1039574932.

Labels: Bug, Needs Triage
⚠️ CI failed on Linux.ubuntu_atlas ⚠️

**CI is still failing on [Linux.ubuntu_atlas](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=44652&view=logs&j=0a287ed6-22f4-5cb4-88b1-d5fcdc4d8b7e)** (Jul 17, 2022)
- test_fastica_simple_different_solvers[6-False]

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=44710&view=logs&j=0a287ed6-22f4-5cb4-88b1-d5fcdc4d8b7e) on Jul 19, 2022

Labels: Bug, Build / CI
⚠️ CI failed on Linux.ubuntu_atlas ⚠️

**CI is still failing on [Linux.ubuntu_atlas](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=44652&view=logs&j=0a287ed6-22f4-5cb4-88b1-d5fcdc4d8b7e)** (Jul 17, 2022)
- test_fastica_simple_different_solvers[6-False]

COMMENT:
This one looks like a real issue with `SKLEARN_TESTS_GLOBAL_RANDOM_SEED=6`.

Labels: Bug, Build / CI
⚠️ CI failed on Linux_Docker.debian_atlas_32bit ⚠️

**CI failed on [Linux_Docker.debian_atlas_32bit](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=44486&view=logs&j=aabdcdc3-bb64-5414-b357-ed024fe8659e)**
Unable to find junit file. Please see link for details.

COMMENT:
This issue should resolve itself. `atomicwrites` was removed from pypi and recreated as a new project that did not include previous versions. The old versions are now available again [on pypi](https://pypi.org/project/atomicwrites/#history).

Labels: Build / CI
⚠️ CI failed on Linux_Docker.debian_atlas_32bit ⚠️

**CI failed on [Linux_Docker.debian_atlas_32bit](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=44486&view=logs&j=aabdcdc3-bb64-5414-b357-ed024fe8659e)**
Unable to find junit file. Please see link for details.

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=44506&view=logs&j=aabdcdc3-bb64-5414-b357-ed024fe8659e)

Labels: Build / CI
⚠️ CI failed on Linux_Docker.debian_atlas_32bit ⚠️

**CI failed on [Linux_Docker.debian_atlas_32bit](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=44486&view=logs&j=aabdcdc3-bb64-5414-b357-ed024fe8659e)**
Unable to find junit file. Please see link for details.

COMMENT:
I'm closing this issue because the issue with `atomicwrites` fixed itself.

Labels: Build / CI
partial plot for MultiOutputRegressor

Not sure whether this is a bug or not.
I tried to use `PartialDependenceDisplay.from_estimator` to see some Parial Dependece plot for couple of features. 
I just grab the example code available in the website and changed it as follows:

```python
pipe = make_pipeline(
    MinMaxScaler(),
    RegressorChain(
        MLPRegressor(
            hidden_layer_sizes=(64, 32),
            learning_rate_init=0.01,
            batch_size=64, 
            max_iter=500,
            early_stopping=True,
            random_state=73
        )
    )
)

common_params = {
    "subsample": 50,
    "n_jobs": 2,
    "grid_resolution": 20,
    #"centered": True,
    "random_state": 73,}

display = PartialDependenceDisplay.from_estimator(
    estimator=pipe,
    X=X_train,
    features=[0, 1],
    feature_names=features[0:2],
    kind="both",
    **common_params,
)

display.figure_.suptitle(
    "Partial dependence of house value on non-location features\n"
    "for the California housing dataset, with MLPRegressor"
)
display.figure_.subplots_adjust(hspace=0.3)
```

After running this simple code, I faced with `ValueError: target must be specified for multi-output regressors`. 
After adding "target=y_train", then I faced with other error mentions `ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().`

Can anyone has any idea about this issue?
Thanks!

COMMENT:
Hi @bachephysicdun , the `target` argument should be an integer, and under the multi-output setting, set to task index for which the PDPs will be calculated.

Labels: Needs Triage
partial plot for MultiOutputRegressor

Not sure whether this is a bug or not.
I tried to use `PartialDependenceDisplay.from_estimator` to see some Parial Dependece plot for couple of features. 
I just grab the example code available in the website and changed it as follows:

```python
pipe = make_pipeline(
    MinMaxScaler(),
    RegressorChain(
        MLPRegressor(
            hidden_layer_sizes=(64, 32),
            learning_rate_init=0.01,
            batch_size=64, 
            max_iter=500,
            early_stopping=True,
            random_state=73
        )
    )
)

common_params = {
    "subsample": 50,
    "n_jobs": 2,
    "grid_resolution": 20,
    #"centered": True,
    "random_state": 73,}

display = PartialDependenceDisplay.from_estimator(
    estimator=pipe,
    X=X_train,
    features=[0, 1],
    feature_names=features[0:2],
    kind="both",
    **common_params,
)

display.figure_.suptitle(
    "Partial dependence of house value on non-location features\n"
    "for the California housing dataset, with MLPRegressor"
)
display.figure_.subplots_adjust(hspace=0.3)
```

After running this simple code, I faced with `ValueError: target must be specified for multi-output regressors`. 
After adding "target=y_train", then I faced with other error mentions `ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().`

Can anyone has any idea about this issue?
Thanks!

COMMENT:
Thanks @MaxwellLZH!

Labels: Needs Triage
page on the website that provides direction to users on how to reach out

from @amueller 
>Hey! Is there a page on the website that summarizes how to reach out and how we prefer people reach out? So far I only see collections of links. I kind of expected the "community" menu item to tell me how to engage with the community, but it currently links to the blog.

>The most concise summary seems to be in https://scikit-learn.org/dev/faq.html#what-s-the-best-way-to-get-help-on-scikit-learn-usage but it's not really the right question and it's a hard place to find, and outdated.

---
Copying text from Discord

This Discord server is intended for communication between the scikit-learn maintainers and community contributors during **Office Hours** and **Sprints**. If you have questions, this is our general workflow:

* **GitHub Discussions** 
     (usage questions such as methodological):  
     https://github.com/scikit-learn/scikit-learn/discussions
* **Stack Overflow**
     (programming questions):
     with tag ‘scikit-learn’
* **GitHub Issue Tracker**
     (bug reports): 
     https://github.com/scikit-learn/scikit-learn/issues
     Please do not ask usage questions on the issue tracker.
* **Discord server**
     (current pull requests):
     Please post any specific PR-related questions on your PR, and you can share a link to your PR on this server during office hours.

Reference on asking questions:
http://matthewrocklin.com/blog/2019/02/28/slack-github

**Calendar **for Office Hours:
https://blog.scikit-learn.org/calendar/

COMMENT:
I am ready to work on this if anyone can help me

Labels: Easy, Documentation
page on the website that provides direction to users on how to reach out

from @amueller 
>Hey! Is there a page on the website that summarizes how to reach out and how we prefer people reach out? So far I only see collections of links. I kind of expected the "community" menu item to tell me how to engage with the community, but it currently links to the blog.

>The most concise summary seems to be in https://scikit-learn.org/dev/faq.html#what-s-the-best-way-to-get-help-on-scikit-learn-usage but it's not really the right question and it's a hard place to find, and outdated.

---
Copying text from Discord

This Discord server is intended for communication between the scikit-learn maintainers and community contributors during **Office Hours** and **Sprints**. If you have questions, this is our general workflow:

* **GitHub Discussions** 
     (usage questions such as methodological):  
     https://github.com/scikit-learn/scikit-learn/discussions
* **Stack Overflow**
     (programming questions):
     with tag ‘scikit-learn’
* **GitHub Issue Tracker**
     (bug reports): 
     https://github.com/scikit-learn/scikit-learn/issues
     Please do not ask usage questions on the issue tracker.
* **Discord server**
     (current pull requests):
     Please post any specific PR-related questions on your PR, and you can share a link to your PR on this server during office hours.

Reference on asking questions:
http://matthewrocklin.com/blog/2019/02/28/slack-github

**Calendar **for Office Hours:
https://blog.scikit-learn.org/calendar/

COMMENT:
The text was added to the support page.

Labels: Easy, Documentation
page on the website that provides direction to users on how to reach out

from @amueller 
>Hey! Is there a page on the website that summarizes how to reach out and how we prefer people reach out? So far I only see collections of links. I kind of expected the "community" menu item to tell me how to engage with the community, but it currently links to the blog.

>The most concise summary seems to be in https://scikit-learn.org/dev/faq.html#what-s-the-best-way-to-get-help-on-scikit-learn-usage but it's not really the right question and it's a hard place to find, and outdated.

---
Copying text from Discord

This Discord server is intended for communication between the scikit-learn maintainers and community contributors during **Office Hours** and **Sprints**. If you have questions, this is our general workflow:

* **GitHub Discussions** 
     (usage questions such as methodological):  
     https://github.com/scikit-learn/scikit-learn/discussions
* **Stack Overflow**
     (programming questions):
     with tag ‘scikit-learn’
* **GitHub Issue Tracker**
     (bug reports): 
     https://github.com/scikit-learn/scikit-learn/issues
     Please do not ask usage questions on the issue tracker.
* **Discord server**
     (current pull requests):
     Please post any specific PR-related questions on your PR, and you can share a link to your PR on this server during office hours.

Reference on asking questions:
http://matthewrocklin.com/blog/2019/02/28/slack-github

**Calendar **for Office Hours:
https://blog.scikit-learn.org/calendar/

COMMENT:
> I am ready to work on this if anyone can help me

hi , is this issue still open ? . if yes then i am ready to help you

Labels: Easy, Documentation
page on the website that provides direction to users on how to reach out

from @amueller 
>Hey! Is there a page on the website that summarizes how to reach out and how we prefer people reach out? So far I only see collections of links. I kind of expected the "community" menu item to tell me how to engage with the community, but it currently links to the blog.

>The most concise summary seems to be in https://scikit-learn.org/dev/faq.html#what-s-the-best-way-to-get-help-on-scikit-learn-usage but it's not really the right question and it's a hard place to find, and outdated.

---
Copying text from Discord

This Discord server is intended for communication between the scikit-learn maintainers and community contributors during **Office Hours** and **Sprints**. If you have questions, this is our general workflow:

* **GitHub Discussions** 
     (usage questions such as methodological):  
     https://github.com/scikit-learn/scikit-learn/discussions
* **Stack Overflow**
     (programming questions):
     with tag ‘scikit-learn’
* **GitHub Issue Tracker**
     (bug reports): 
     https://github.com/scikit-learn/scikit-learn/issues
     Please do not ask usage questions on the issue tracker.
* **Discord server**
     (current pull requests):
     Please post any specific PR-related questions on your PR, and you can share a link to your PR on this server during office hours.

Reference on asking questions:
http://matthewrocklin.com/blog/2019/02/28/slack-github

**Calendar **for Office Hours:
https://blog.scikit-learn.org/calendar/

COMMENT:
> hi , is this issue still open ? . if yes then i am ready to help you

Hi @ryuusama09 a pull request is already open. Feel free to pick any other [good first issue](https://github.com/scikit-learn/scikit-learn/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) to start contributing.

Labels: Easy, Documentation