Talip7/scikit-learn-issues-multilabel huggingface dataset:
Fix Axes3D matplotlib deprecation warning in examples

See in #22547

```
MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6.  This is consistent with other Axes classes
```

We need to replace a line like this:
```py
ax = Axes3D(fig, elev=elev, azim=azim, rect=[0, 0, 0.95, 1])
```

by:
```py
ax = fig.add_subplot(111, projection="3d", elev=elev, azim=azim)
ax.set_position([0, 0, 0.95, 1])
```

For matplotlib < 3.2 (matplotlib 3.1.2 is our minimum supported version of matplotlib) we need to have this import:
```py
# unused but required import for doing 3d projections with matplotlib < 3.2
import mpl_toolkits.mplot3d  # noqa: F401
```
see https://github.com/scikit-learn/scikit-learn/pull/22594#issuecomment-1050127303 for more details.

### List of examples affected 
through `git grep Axes3D examples`:
- [x] examples/cluster/plot_cluster_iris.py #22594
- [x] examples/cluster/plot_ward_structured_vs_unstructured.py #22631
- [x] examples/datasets/plot_iris_dataset.py #22640
- [x] examples/decomposition/plot_pca_3d.py #22591
- [x] examples/decomposition/plot_pca_iris.py #22622
- [x] examples/inspection/plot_partial_dependence.py #22654
- [x] examples/manifold/plot_compare_methods.py done as part of #22679
- [ ] examples/manifold/plot_manifold_sphere.py

### If you are interested to work on this issue

- mention in a comment which file you want to work on, so that different people can work on this issue in parallel
- open a PR changing only this file

COMMENT:
Working on examples/datasets/plot_iris_dataset.py

Labels: Documentation, good first issue, help wanted, Meta-issue
Fix Axes3D matplotlib deprecation warning in examples

See in #22547

```
MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6.  This is consistent with other Axes classes
```

We need to replace a line like this:
```py
ax = Axes3D(fig, elev=elev, azim=azim, rect=[0, 0, 0.95, 1])
```

by:
```py
ax = fig.add_subplot(111, projection="3d", elev=elev, azim=azim)
ax.set_position([0, 0, 0.95, 1])
```

For matplotlib < 3.2 (matplotlib 3.1.2 is our minimum supported version of matplotlib) we need to have this import:
```py
# unused but required import for doing 3d projections with matplotlib < 3.2
import mpl_toolkits.mplot3d  # noqa: F401
```
see https://github.com/scikit-learn/scikit-learn/pull/22594#issuecomment-1050127303 for more details.

### List of examples affected 
through `git grep Axes3D examples`:
- [x] examples/cluster/plot_cluster_iris.py #22594
- [x] examples/cluster/plot_ward_structured_vs_unstructured.py #22631
- [x] examples/datasets/plot_iris_dataset.py #22640
- [x] examples/decomposition/plot_pca_3d.py #22591
- [x] examples/decomposition/plot_pca_iris.py #22622
- [x] examples/inspection/plot_partial_dependence.py #22654
- [x] examples/manifold/plot_compare_methods.py done as part of #22679
- [ ] examples/manifold/plot_manifold_sphere.py

### If you are interested to work on this issue

- mention in a comment which file you want to work on, so that different people can work on this issue in parallel
- open a PR changing only this file

COMMENT:
If I am not mistaken, in `examples/manifold/plot_manifold_sphere.py`,  Axes3D is only used (as the comment inside the code indicates) for "silence pyflakes".

Labels: Documentation, good first issue, help wanted, Meta-issue
Fix Axes3D matplotlib deprecation warning in examples

See in #22547

```
MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6.  This is consistent with other Axes classes
```

We need to replace a line like this:
```py
ax = Axes3D(fig, elev=elev, azim=azim, rect=[0, 0, 0.95, 1])
```

by:
```py
ax = fig.add_subplot(111, projection="3d", elev=elev, azim=azim)
ax.set_position([0, 0, 0.95, 1])
```

For matplotlib < 3.2 (matplotlib 3.1.2 is our minimum supported version of matplotlib) we need to have this import:
```py
# unused but required import for doing 3d projections with matplotlib < 3.2
import mpl_toolkits.mplot3d  # noqa: F401
```
see https://github.com/scikit-learn/scikit-learn/pull/22594#issuecomment-1050127303 for more details.

### List of examples affected 
through `git grep Axes3D examples`:
- [x] examples/cluster/plot_cluster_iris.py #22594
- [x] examples/cluster/plot_ward_structured_vs_unstructured.py #22631
- [x] examples/datasets/plot_iris_dataset.py #22640
- [x] examples/decomposition/plot_pca_3d.py #22591
- [x] examples/decomposition/plot_pca_iris.py #22622
- [x] examples/inspection/plot_partial_dependence.py #22654
- [x] examples/manifold/plot_compare_methods.py done as part of #22679
- [ ] examples/manifold/plot_manifold_sphere.py

### If you are interested to work on this issue

- mention in a comment which file you want to work on, so that different people can work on this issue in parallel
- open a PR changing only this file

COMMENT:
Hello everyone, may I work on examples/decomposition/plot_pca_iris.py.

Labels: Documentation, good first issue, help wanted, Meta-issue
Fix Axes3D matplotlib deprecation warning in examples

See in #22547

```
MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6.  This is consistent with other Axes classes
```

We need to replace a line like this:
```py
ax = Axes3D(fig, elev=elev, azim=azim, rect=[0, 0, 0.95, 1])
```

by:
```py
ax = fig.add_subplot(111, projection="3d", elev=elev, azim=azim)
ax.set_position([0, 0, 0.95, 1])
```

For matplotlib < 3.2 (matplotlib 3.1.2 is our minimum supported version of matplotlib) we need to have this import:
```py
# unused but required import for doing 3d projections with matplotlib < 3.2
import mpl_toolkits.mplot3d  # noqa: F401
```
see https://github.com/scikit-learn/scikit-learn/pull/22594#issuecomment-1050127303 for more details.

### List of examples affected 
through `git grep Axes3D examples`:
- [x] examples/cluster/plot_cluster_iris.py #22594
- [x] examples/cluster/plot_ward_structured_vs_unstructured.py #22631
- [x] examples/datasets/plot_iris_dataset.py #22640
- [x] examples/decomposition/plot_pca_3d.py #22591
- [x] examples/decomposition/plot_pca_iris.py #22622
- [x] examples/inspection/plot_partial_dependence.py #22654
- [x] examples/manifold/plot_compare_methods.py done as part of #22679
- [ ] examples/manifold/plot_manifold_sphere.py

### If you are interested to work on this issue

- mention in a comment which file you want to work on, so that different people can work on this issue in parallel
- open a PR changing only this file

COMMENT:
> Hello everyone, may I work on examples/decomposition/plot_pca_iris.py.

Hi @Aditi840, 
It looks like this one was tackled here: https://github.com/scikit-learn/scikit-learn/pull/22622

Labels: Documentation, good first issue, help wanted, Meta-issue
Fix Axes3D matplotlib deprecation warning in examples

See in #22547

```
MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6.  This is consistent with other Axes classes
```

We need to replace a line like this:
```py
ax = Axes3D(fig, elev=elev, azim=azim, rect=[0, 0, 0.95, 1])
```

by:
```py
ax = fig.add_subplot(111, projection="3d", elev=elev, azim=azim)
ax.set_position([0, 0, 0.95, 1])
```

For matplotlib < 3.2 (matplotlib 3.1.2 is our minimum supported version of matplotlib) we need to have this import:
```py
# unused but required import for doing 3d projections with matplotlib < 3.2
import mpl_toolkits.mplot3d  # noqa: F401
```
see https://github.com/scikit-learn/scikit-learn/pull/22594#issuecomment-1050127303 for more details.

### List of examples affected 
through `git grep Axes3D examples`:
- [x] examples/cluster/plot_cluster_iris.py #22594
- [x] examples/cluster/plot_ward_structured_vs_unstructured.py #22631
- [x] examples/datasets/plot_iris_dataset.py #22640
- [x] examples/decomposition/plot_pca_3d.py #22591
- [x] examples/decomposition/plot_pca_iris.py #22622
- [x] examples/inspection/plot_partial_dependence.py #22654
- [x] examples/manifold/plot_compare_methods.py done as part of #22679
- [ ] examples/manifold/plot_manifold_sphere.py

### If you are interested to work on this issue

- mention in a comment which file you want to work on, so that different people can work on this issue in parallel
- open a PR changing only this file

COMMENT:
> It looks like this one was tackled here: https://github.com/scikit-learn/scikit-learn/pull/22622

Indeed thanks for noticing, I updated the top post description!

Labels: Documentation, good first issue, help wanted, Meta-issue
Fix Axes3D matplotlib deprecation warning in examples

See in #22547

```
MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6.  This is consistent with other Axes classes
```

We need to replace a line like this:
```py
ax = Axes3D(fig, elev=elev, azim=azim, rect=[0, 0, 0.95, 1])
```

by:
```py
ax = fig.add_subplot(111, projection="3d", elev=elev, azim=azim)
ax.set_position([0, 0, 0.95, 1])
```

For matplotlib < 3.2 (matplotlib 3.1.2 is our minimum supported version of matplotlib) we need to have this import:
```py
# unused but required import for doing 3d projections with matplotlib < 3.2
import mpl_toolkits.mplot3d  # noqa: F401
```
see https://github.com/scikit-learn/scikit-learn/pull/22594#issuecomment-1050127303 for more details.

### List of examples affected 
through `git grep Axes3D examples`:
- [x] examples/cluster/plot_cluster_iris.py #22594
- [x] examples/cluster/plot_ward_structured_vs_unstructured.py #22631
- [x] examples/datasets/plot_iris_dataset.py #22640
- [x] examples/decomposition/plot_pca_3d.py #22591
- [x] examples/decomposition/plot_pca_iris.py #22622
- [x] examples/inspection/plot_partial_dependence.py #22654
- [x] examples/manifold/plot_compare_methods.py done as part of #22679
- [ ] examples/manifold/plot_manifold_sphere.py

### If you are interested to work on this issue

- mention in a comment which file you want to work on, so that different people can work on this issue in parallel
- open a PR changing only this file

COMMENT:
Working on [examples/manifold/plot_manifold_sphere.py](https://github.com/scikit-learn/scikit-learn/blob/main/examples/manifold/plot_manifold_sphere.py)

Labels: Documentation, good first issue, help wanted, Meta-issue
`sklearn.neighbors.VALID_METRICS['brute']` has duplicate keyword: "cosine".

### Describe the bug

The constant:`sklearn.neighbors.VALID_METRICS['brute']` returns duplicate "cosine" keyword.
It seems harmless, but I think it should return a unique keyword list to avoid unnecessary confusion.

The constant is defined here:

https://github.com/scikit-learn/scikit-learn/blob/691972a7cf04e7a8918b907556b4e9904f82bd0c/sklearn/neighbors/_base.py#L40-L69

Removing `cosine` from the latter list looks OK, but I think using `set().union` is more robust.

```py
brute=(
    set(PAIRWISE_DISTANCE_FUNCTIONS.keys()).union([
        "braycurtis",
        "canberra",
        "chebyshev",
        "correlation",
        "cosine",
        "dice",
        ...
    ])
)
```

### Steps/Code to Reproduce

Run the following codes on the colab.

```
!pip install scikit-learn -Uq
```

```py
import sklearn.neighbors
brute_metrics = sorted(sklearn.neighbors.VALID_METRICS['brute'])
print(len(brute_metrics), len(set(brute_metrics)))
print(brute_metrics[5:7])
```

The result will be:

```txt
29 28
['cosine', 'cosine']
```


### Expected Results

`sklearn.neighbors.VALID_METRICS['brute']` returns unique keywords

### Actual Results

```py
import sklearn.neighbors
brute_metrics = sorted(sklearn.neighbors.VALID_METRICS['brute'])
assert len(brute_metrics) == len(set(brute_metrics)), "detect duplicates!"
```

Got:

```py
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
[<ipython-input-13-279d32fcf741>](https://localhost:8080/#) in <module>()
      1 import sklearn.neighbors
      2 brute_metrics = sorted(sklearn.neighbors.VALID_METRICS['brute'])
----> 3 assert len(brute_metrics) == len(set(brute_metrics)), "detect duplicates!"
      4 
      5 

AssertionError: detect duplicates!
```



### Versions

```shell
System:
    python: 3.7.12 (default, Jan 15 2022, 18:48:18)  [GCC 7.5.0]
executable: /usr/bin/python3
   machine: Linux-5.4.144+-x86_64-with-Ubuntu-18.04-bionic

Python dependencies:
          pip: 21.1.3
   setuptools: 57.4.0
      sklearn: 1.0.2
        numpy: 1.21.5
        scipy: 1.4.1
       Cython: 0.29.28
       pandas: 1.3.5
   matplotlib: 3.2.2
       joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True
```
```

COMMENT:
Thanks @i-aki-y for the report. The union of sets approach seems good. Would you like to submit a PR ?

Labels: Bug
`sklearn.neighbors.VALID_METRICS['brute']` has duplicate keyword: "cosine".

### Describe the bug

The constant:`sklearn.neighbors.VALID_METRICS['brute']` returns duplicate "cosine" keyword.
It seems harmless, but I think it should return a unique keyword list to avoid unnecessary confusion.

The constant is defined here:

https://github.com/scikit-learn/scikit-learn/blob/691972a7cf04e7a8918b907556b4e9904f82bd0c/sklearn/neighbors/_base.py#L40-L69

Removing `cosine` from the latter list looks OK, but I think using `set().union` is more robust.

```py
brute=(
    set(PAIRWISE_DISTANCE_FUNCTIONS.keys()).union([
        "braycurtis",
        "canberra",
        "chebyshev",
        "correlation",
        "cosine",
        "dice",
        ...
    ])
)
```

### Steps/Code to Reproduce

Run the following codes on the colab.

```
!pip install scikit-learn -Uq
```

```py
import sklearn.neighbors
brute_metrics = sorted(sklearn.neighbors.VALID_METRICS['brute'])
print(len(brute_metrics), len(set(brute_metrics)))
print(brute_metrics[5:7])
```

The result will be:

```txt
29 28
['cosine', 'cosine']
```


### Expected Results

`sklearn.neighbors.VALID_METRICS['brute']` returns unique keywords

### Actual Results

```py
import sklearn.neighbors
brute_metrics = sorted(sklearn.neighbors.VALID_METRICS['brute'])
assert len(brute_metrics) == len(set(brute_metrics)), "detect duplicates!"
```

Got:

```py
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
[<ipython-input-13-279d32fcf741>](https://localhost:8080/#) in <module>()
      1 import sklearn.neighbors
      2 brute_metrics = sorted(sklearn.neighbors.VALID_METRICS['brute'])
----> 3 assert len(brute_metrics) == len(set(brute_metrics)), "detect duplicates!"
      4 
      5 

AssertionError: detect duplicates!
```



### Versions

```shell
System:
    python: 3.7.12 (default, Jan 15 2022, 18:48:18)  [GCC 7.5.0]
executable: /usr/bin/python3
   machine: Linux-5.4.144+-x86_64-with-Ubuntu-18.04-bionic

Python dependencies:
          pip: 21.1.3
   setuptools: 57.4.0
      sklearn: 1.0.2
        numpy: 1.21.5
        scipy: 1.4.1
       Cython: 0.29.28
       pandas: 1.3.5
   matplotlib: 3.2.2
       joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True
```
```

COMMENT:
@jeremiedbb OK, I will make a PR.

Labels: Bug
Unable to successfully install scikit-learn development version with MacBookPro with chip Apple M1 Pro

### Describe the bug

I installed the development version of scikit-learn on my computer (MacBookPro with chip Apple M1 Pro). When I ran pytest I got the following error: 
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```

I investigated what's going on an this is the result: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

I'm using a conda environment. I used the Miniforge3-MacOSX-arm64 download from here: https://github.com/conda-forge/miniforge#miniforge

This is the content of my sklearn-dev conda environment: 
https://gist.github.com/marenwestermann/c01fc4d3044522e329ce83d16680e1a5

### Steps/Code to Reproduce

```
pytest
```

```
python -vvv -c "import sklearn"
```

### Expected Results

The expected result would be that when the command `pytest` is run all test are either skipped or are successful. 

### Actual Results

Pytest result:
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```
Further investigation: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

### Versions

```shell
function>
```

COMMENT:
This could be an issue with the latest version of `pytest`. Can you try downgrading to `pytest==6.2.5` and see if you get the same error?

Labels: Bug, Build / CI
Unable to successfully install scikit-learn development version with MacBookPro with chip Apple M1 Pro

### Describe the bug

I installed the development version of scikit-learn on my computer (MacBookPro with chip Apple M1 Pro). When I ran pytest I got the following error: 
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```

I investigated what's going on an this is the result: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

I'm using a conda environment. I used the Miniforge3-MacOSX-arm64 download from here: https://github.com/conda-forge/miniforge#miniforge

This is the content of my sklearn-dev conda environment: 
https://gist.github.com/marenwestermann/c01fc4d3044522e329ce83d16680e1a5

### Steps/Code to Reproduce

```
pytest
```

```
python -vvv -c "import sklearn"
```

### Expected Results

The expected result would be that when the command `pytest` is run all test are either skipped or are successful. 

### Actual Results

Pytest result:
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```
Further investigation: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

### Versions

```shell
function>
```

COMMENT:
Maybe there was a transient problem in one of the packages that was updated between the 2 envs.

Labels: Bug, Build / CI
Unable to successfully install scikit-learn development version with MacBookPro with chip Apple M1 Pro

### Describe the bug

I installed the development version of scikit-learn on my computer (MacBookPro with chip Apple M1 Pro). When I ran pytest I got the following error: 
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```

I investigated what's going on an this is the result: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

I'm using a conda environment. I used the Miniforge3-MacOSX-arm64 download from here: https://github.com/conda-forge/miniforge#miniforge

This is the content of my sklearn-dev conda environment: 
https://gist.github.com/marenwestermann/c01fc4d3044522e329ce83d16680e1a5

### Steps/Code to Reproduce

```
pytest
```

```
python -vvv -c "import sklearn"
```

### Expected Results

The expected result would be that when the command `pytest` is run all test are either skipped or are successful. 

### Actual Results

Pytest result:
```
(sklearn-dev) ➜  scikit-learn git:(main) pytest
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/maren/Documents/scikit-learn, configfile: setup.cfg, testpaths: sklearn
plugins: xdist-2.5.0, forked-1.4.0, cov-3.0.0
collecting ... [1]    54294 killed     pytest
```
Further investigation: 
https://gist.github.com/marenwestermann/9ffddb7a2f0ef6798d350f3595997ed1

### Versions

```shell
function>
```

COMMENT:
From your logs, it looks like the compiler being used is not the conda-forge one. Can you try install the compilers first?

```python
conda create -n sklearn-env -c conda-forge python=3.9 numpy scipy cython compilers
conda activate sklearn-env
mamba install -c conda-forge joblib threadpoolctl pytest
make clean
pip install --verbose --no-build-isolation --editable .
```

(An alternative is to deactivate and reactivate the environment after installing `compilers`)

Labels: Bug, Build / CI