Talip7/scikit-learn-issues-multilabel huggingface dataset:
Deprecation warning with scipy=1.9.0

### Describe the bug

When running a fit with a Ride regression model we get:

> DeprecationWarning: The 'sym_pos' keyword is deprecated and should be replaced by using 'assume_a = "pos"'. 'sym_pos' will be removed in SciPy 1.11.0.

Looking through the SciPy release notes, sym_pos was actually deprecated about 5 years ago, they just forgot to add the deprecation warning. Now that they have, it is probably best to make this change now before the sym_pos keyword is actually removed.

The argument is used 4 times within sklearn/linear_model/_ridge.py.



### Steps/Code to Reproduce

```
import warnings

from sklearn import linear_model

warnings.simplefilter('always', DeprecationWarning)

reg = linear_model.Ridge(alpha=0.5, solver='cholesky')
reg.fit([[0, 0], [0, 0], [1, 1]], [0, 0.1, 1])
```

### Expected Results

No warnings generated

### Actual Results

/usr/local/lib/python3.10/site-packages/sklearn/linear_model/_ridge.py:212: DeprecationWarning: The 'sym_pos' keyword is deprecated and should be replaced by using 'assume_a = "pos"'. 'sym_pos' will be removed in SciPy 1.11.0.
  return linalg.solve(A, Xy, sym_pos=True, overwrite_a=True).T

### Versions

```shell
System:
    python: 3.10.5 (main, Jul 13 2022, 05:45:22) [GCC 10.2.1 20210110]
executable: /usr/local/bin/python
   machine: Linux-5.15.0-43-generic-x86_64-with-glibc2.31

Python dependencies:
      sklearn: 1.1.1
          pip: 22.1.2
   setuptools: 58.1.0
        numpy: 1.23.1
        scipy: 1.9.0
       Cython: None
       pandas: 1.4.3
   matplotlib: 3.5.2
       joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /usr/local/lib/python3.10/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
        version: None
    num_threads: 32

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /usr/local/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-742d56dc.3.20.so
        version: 0.3.20
threading_layer: pthreads
   architecture: Zen
    num_threads: 32

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /usr/local/lib/python3.10/site-packages/scipy.libs/libopenblasp-r0-9f9f5dbc.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen
    num_threads: 32
```

COMMENT:
I placed https://github.com/scikit-learn/scikit-learn/pull/23617 on the 1.1.2 milestone. I expect it to be a part of `1.1.2`.

As for the changelog, we normally do not add this type of maintenance fixes to the change log. Technically nothing broke, it's more to prevent future breakage. No strong opinion tho.

Labels: Bug
Binder link does not work

### Describe the issue linked to the documentation

I have tried the binder link given here: [link](https://scikit-learn.org/stable/auto_examples/ensemble/plot_adaboost_hastie_10_2.html#sphx-glr-auto-examples-ensemble-plot-adaboost-hastie-10-2-py)

but it does not work.


### Suggest a potential alternative/fix

_No response_

COMMENT:
It seems like the python version in binder should be upgraded.

![image](https://user-images.githubusercontent.com/16646940/182506052-8a532293-1e16-4675-b090-1a3d8b8b9b25.png)

Labels: Documentation, Needs Triage
Binder link does not work

### Describe the issue linked to the documentation

I have tried the binder link given here: [link](https://scikit-learn.org/stable/auto_examples/ensemble/plot_adaboost_hastie_10_2.html#sphx-glr-auto-examples-ensemble-plot-adaboost-hastie-10-2-py)

but it does not work.


### Suggest a potential alternative/fix

_No response_

COMMENT:
Thanks @MaxwellLZH

Labels: Documentation, Needs Triage
Permutation feature importance documentation page with misleading code

### Describe the issue linked to the documentation

In the documentation page of the feature importance algorithm (https://scikit-learn.org/stable/modules/permutation_importance.html) there are misleading code snippets.

When performing the following code:
```
from sklearn.inspection import permutation_importance
r = permutation_importance(model, X_val, y_val,
                           n_repeats=30,
                           random_state=0)

for i in r.importances_mean.argsort()[::-1]:
    if r.importances_mean[i] - 2 * r.importances_std[i] > 0:
        print(f"{diabetes.feature_names[i]:<8}"
              f"{r.importances_mean[i]:.3f}"
              f" +/- {r.importances_std[i]:.3f}")
```

The loop uses ```i``` to describe the importances from the diabetes' features. However, when using ```.argsort()``` function on the ```r``` variable, the ```i``` refers to the sorted importances found, not relating to the original dataset's features. One could wrongly interpret the variables' importances if no double checking is performed in this case. Please fix it the documentation so anyone can be affected by this.

### Suggest a potential alternative/fix

I used the ```enumerate``` function to map back the variables from the dataframe:
```
from sklearn.inspection import permutation_importance
r = permutation_importance(model, X_val, y_val,
                           n_repeats=30,
                           random_state=0)

for n, i in enumerate(r.importances_mean.argsort()[::-1]):
    if r.importances_mean[i] - 2 * r.importances_std[i] > 0:
        print(f"{diabetes.feature_names[n]:<8}"
              f"{r.importances_mean[i]:.3f}"
              f" +/- {r.importances_std[i]:.3f}")
```

This way the importances were plotted accordingly.

COMMENT:
I think the snippet is correct. 

`r.importances_mean[i]` is the score of the feature whose name is `diabetes.feature_names[i]`. Both arrays are indexed on the same features, in the same order (it originally comes from the `X` parameter).

Taking the `argsort()[::-1]` of `r.importances_mean`  gives us an array of feature indices, sorted by decreasing importance.

Labels: Documentation, Needs Triage
Permutation feature importance documentation page with misleading code

### Describe the issue linked to the documentation

In the documentation page of the feature importance algorithm (https://scikit-learn.org/stable/modules/permutation_importance.html) there are misleading code snippets.

When performing the following code:
```
from sklearn.inspection import permutation_importance
r = permutation_importance(model, X_val, y_val,
                           n_repeats=30,
                           random_state=0)

for i in r.importances_mean.argsort()[::-1]:
    if r.importances_mean[i] - 2 * r.importances_std[i] > 0:
        print(f"{diabetes.feature_names[i]:<8}"
              f"{r.importances_mean[i]:.3f}"
              f" +/- {r.importances_std[i]:.3f}")
```

The loop uses ```i``` to describe the importances from the diabetes' features. However, when using ```.argsort()``` function on the ```r``` variable, the ```i``` refers to the sorted importances found, not relating to the original dataset's features. One could wrongly interpret the variables' importances if no double checking is performed in this case. Please fix it the documentation so anyone can be affected by this.

### Suggest a potential alternative/fix

I used the ```enumerate``` function to map back the variables from the dataframe:
```
from sklearn.inspection import permutation_importance
r = permutation_importance(model, X_val, y_val,
                           n_repeats=30,
                           random_state=0)

for n, i in enumerate(r.importances_mean.argsort()[::-1]):
    if r.importances_mean[i] - 2 * r.importances_std[i] > 0:
        print(f"{diabetes.feature_names[n]:<8}"
              f"{r.importances_mean[i]:.3f}"
              f" +/- {r.importances_std[i]:.3f}")
```

This way the importances were plotted accordingly.

COMMENT:
I agree with https://github.com/scikit-learn/scikit-learn/issues/24064#issuecomment-1200965725 and that the snippet is correct. Here is a quick code example for using `argsort()[::-1]`:

```python
import numpy as np

names = np.asarray(["a", "b", "c"])
importances = np.asarray([0.2, 1.0, 0.8])
sorted_idx = importances.argsort()[::-1]

print("sorted_idx:", sorted_idx)
print("sorted_names:", names[sorted_idx])
print("sorted_importances:", importances[sorted_idx])

# sorted_idx: [1 2 0]
# sorted_names: ['b' 'c' 'a']
# sorted_importances: [1.  0.8 0.2]
```

Note how `sorted_idx[0]` is 1 which means that `names[1]` or "b" is the feature with the highest importance.

Labels: Documentation, Needs Triage
CI/Pre-commit Incompatibility between black and flake8

### Describe the workflow you want to enable

While `black` *tries* to make line lengths 88 characters maximum, there are cases where it will leave the code alone. On the other hand `flake8` is a strict check whether the line is longer than 88 characters, so in cases where the lines are slightly over 88 characters, `black` might say it's fine and `flake8` will complain. This is currently happening in #24062, which doesn't touch any Python files. Is there any reason we don't incorporate the guidance in the `black` [docs](https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8) to harmonize them?

### Describe your proposed solution

Incorporate the guidance in the `black` [docs](https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8) into the `.pre-commit-config.yaml` file, and update the CI tests.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

If you decide to make this change, I'm happy to work on it. I know how to fix the `.pre-commit-config.yaml` file, but I would need guidance on anything additional for the automatic tests that run on PRs.

COMMENT:
I think that we already have those implemented in `setup.cfg`: https://github.com/scikit-learn/scikit-learn/blob/main/setup.cfg

The failures in #24062 are about some docstrings and I don't `black` will reformat the docstring at any point.

The weird point here is that we should have detected those long lines earlier but the CIs were not failing. I saw that `flake8` released `5.0.0` recently, it might be linked to this.

Labels: New Feature, Needs Triage
CI/Pre-commit Incompatibility between black and flake8

### Describe the workflow you want to enable

While `black` *tries* to make line lengths 88 characters maximum, there are cases where it will leave the code alone. On the other hand `flake8` is a strict check whether the line is longer than 88 characters, so in cases where the lines are slightly over 88 characters, `black` might say it's fine and `flake8` will complain. This is currently happening in #24062, which doesn't touch any Python files. Is there any reason we don't incorporate the guidance in the `black` [docs](https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8) to harmonize them?

### Describe your proposed solution

Incorporate the guidance in the `black` [docs](https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8) into the `.pre-commit-config.yaml` file, and update the CI tests.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

If you decide to make this change, I'm happy to work on it. I know how to fix the `.pre-commit-config.yaml` file, but I would need guidance on anything additional for the automatic tests that run on PRs.

COMMENT:
Oh, I'm relatively new to `pre-commit` and played around with it elsewhere last week using just the `.pre-commit-config.yaml` and `args` to configure all the `flake8` and `black` options &ndash; good to know that this can also be done in separate files. Lots of config files to keep track of, but I guess the advantage is that when you run `flake8` or `black` on individual files it uses the same configuration as the pre-commit hook.

Labels: New Feature, Needs Triage
> The Conference Paper Suggested has helped us to do detail analysis for our Research Activity

> The Conference Paper Suggested has helped us to do detail analysis for our Research Activity

Thanks for Reply. Will Surely revert you back with new article..

_Originally posted by @sujataoak799 in https://github.com/scikit-learn/scikit-learn/issues/24055#issuecomment-1200134792_

COMMENT:
Any article on machine learning with DevOps!!!!!

Labels: Needs Triage
⚠️ CI failed on Wheel builder ⚠️

**CI is still failing on [Wheel builder](https://github.com/scikit-learn/scikit-learn/actions/runs/2768157160)** (Jul 31, 2022)

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://github.com/scikit-learn/scikit-learn/actions/runs/2772243666) on Aug 01, 2022

Labels: Needs Triage
URL to PCA mle papers broken in docs

### Describe the issue linked to the documentation

Some urls to papers in the [PCA docs](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html#sklearn.decomposition.PCA) no longer work. Here

>For n_components == ‘mle’, this class uses the method from: [Minka, T. P.. “Automatic choice of dimensionality for PCA”. In NIPS, pp. 598-604](https://tminka.github.io/papers/pca/minka-pca.pdf)

And here

>Implements the probabilistic PCA model from: [Tipping, M. E., and Bishop, C. M. (1999). “Probabilistic principal component analysis”. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 61(3), 611-622.](http://www.miketipping.com/papers/met-mppca.pdf) via the score and score_samples methods.

### Suggest a potential alternative/fix

Updated urls, respectively:

- https://tminka.github.io/papers/pca/minka-pca.pdf

- http://www.miketipping.com/papers/met-mppca.pdf

COMMENT:
My bad. They work but in Jupiter they gave me an error. All good.

Labels: Documentation, Needs Triage
Generalized Scores for Multi-Class Imbalanced Classification

### Describe the workflow you want to enable

We wish to extend Matthew coefficient and F1 to multi- class problems.

### Describe your proposed solution

We already generated a pypi package
https://pypi.org/project/matthew-Coef-MultiClass/  which supports this. 

We created a unique function that follows the signature pf metrics._classification.py  current solution for the binary case
I will be glad to add this solution 

### Describe alternatives you've considered, if relevant

The following functions performs the required  (as an alternative to use our own package):

```python
class AVERAG_TYPE(Enum):
    MATTHEW_GEN = 2
    F1_GEN = 3

def generalized_matthew(y_true,y_pred,labels,ave_type=AVERAG_TYPE.MATTHEW_GEN.value):

    # A utitliy function which normalizes the confusion and perfroms the relevant average
    def norm_confusion_mat(conf_mat, average, dimension_size):
        m1 = conf_mat / np.sum(conf_mat, axis=1)
        m2 = conf_mat / np.sum(conf_mat, axis=0)

        return [[average([m1[i, j], m2[j][i]])
                 for i in range(dimension_size)] for j in range(dimension_size)]

    # A utitliy function that perfroms the generaized score of F1 . it calculates the hamonic average
    # over the trace of the normalized confusion matrix
    def gen_f1_scalar_op(h_conf_mat):
        l_mat = len(h_conf_mat)
        return st.mstats.hmean([h_conf_mat[i][i] for i in range(l_mat)])

    dimension_size =len(labels)
    conf_mat=confusion_matrix(y_true=y_true,y_pred=y_pred ,labels=labels)
    if ave_type == AVERAG_TYPE.MATTHEW_GEN.value:
        av_func =st.mstats.gmean
        scalar_op =np.linalg.det
    elif ave_type ==AVERAG_TYPE.F1_GEN.value:
        av_func = st.mstats.hmean
        scalar_op =gen_f1_scalar_op

    G_mat= norm_confusion_mat(conf_mat, av_func, dimension_size)
    return scalar_op(G_mat)
```


### Additional context

I wish to stress that there is a sound mathematical work behind this generalization which is soon to be published . The paper will be gladly provided by either myself or Uri Itai

COMMENT:
My pull request

https://github.com/scikit-learn/scikit-learn/pull/24059

Labels: New Feature, Needs Decision - Include Feature
Generalized Scores for Multi-Class Imbalanced Classification

### Describe the workflow you want to enable

We wish to extend Matthew coefficient and F1 to multi- class problems.

### Describe your proposed solution

We already generated a pypi package
https://pypi.org/project/matthew-Coef-MultiClass/  which supports this. 

We created a unique function that follows the signature pf metrics._classification.py  current solution for the binary case
I will be glad to add this solution 

### Describe alternatives you've considered, if relevant

The following functions performs the required  (as an alternative to use our own package):

```python
class AVERAG_TYPE(Enum):
    MATTHEW_GEN = 2
    F1_GEN = 3

def generalized_matthew(y_true,y_pred,labels,ave_type=AVERAG_TYPE.MATTHEW_GEN.value):

    # A utitliy function which normalizes the confusion and perfroms the relevant average
    def norm_confusion_mat(conf_mat, average, dimension_size):
        m1 = conf_mat / np.sum(conf_mat, axis=1)
        m2 = conf_mat / np.sum(conf_mat, axis=0)

        return [[average([m1[i, j], m2[j][i]])
                 for i in range(dimension_size)] for j in range(dimension_size)]

    # A utitliy function that perfroms the generaized score of F1 . it calculates the hamonic average
    # over the trace of the normalized confusion matrix
    def gen_f1_scalar_op(h_conf_mat):
        l_mat = len(h_conf_mat)
        return st.mstats.hmean([h_conf_mat[i][i] for i in range(l_mat)])

    dimension_size =len(labels)
    conf_mat=confusion_matrix(y_true=y_true,y_pred=y_pred ,labels=labels)
    if ave_type == AVERAG_TYPE.MATTHEW_GEN.value:
        av_func =st.mstats.gmean
        scalar_op =np.linalg.det
    elif ave_type ==AVERAG_TYPE.F1_GEN.value:
        av_func = st.mstats.hmean
        scalar_op =gen_f1_scalar_op

    G_mat= norm_confusion_mat(conf_mat, av_func, dimension_size)
    return scalar_op(G_mat)
```


### Additional context

I wish to stress that there is a sound mathematical work behind this generalization which is soon to be published . The paper will be gladly provided by either myself or Uri Itai

COMMENT:
Thank you for the feature request. Every feature we include has a [maintenance cost](http://scikit-learn.org/dev/faq.html#why-are-you-so-selective-on-what-algorithms-you-include-in-scikit-learn). Our maintainers are mostly volunteers. For a new feature to be included, we need evidence that it is often useful and, ideally, [well-established](http://scikit-learn.org/dev/faq.html#what-are-the-inclusion-criteria-for-new-algorithms) in the literature or in practice.

Given that the proposed method has not been published yet, I do not think it meets scikit-learn's [includion critetion](https://scikit-learn.org/dev/faq.html#what-are-the-inclusion-criteria-for-new-algorithms).

Labels: New Feature, Needs Decision - Include Feature
Generalized Scores for Multi-Class Imbalanced Classification

### Describe the workflow you want to enable

We wish to extend Matthew coefficient and F1 to multi- class problems.

### Describe your proposed solution

We already generated a pypi package
https://pypi.org/project/matthew-Coef-MultiClass/  which supports this. 

We created a unique function that follows the signature pf metrics._classification.py  current solution for the binary case
I will be glad to add this solution 

### Describe alternatives you've considered, if relevant

The following functions performs the required  (as an alternative to use our own package):

```python
class AVERAG_TYPE(Enum):
    MATTHEW_GEN = 2
    F1_GEN = 3

def generalized_matthew(y_true,y_pred,labels,ave_type=AVERAG_TYPE.MATTHEW_GEN.value):

    # A utitliy function which normalizes the confusion and perfroms the relevant average
    def norm_confusion_mat(conf_mat, average, dimension_size):
        m1 = conf_mat / np.sum(conf_mat, axis=1)
        m2 = conf_mat / np.sum(conf_mat, axis=0)

        return [[average([m1[i, j], m2[j][i]])
                 for i in range(dimension_size)] for j in range(dimension_size)]

    # A utitliy function that perfroms the generaized score of F1 . it calculates the hamonic average
    # over the trace of the normalized confusion matrix
    def gen_f1_scalar_op(h_conf_mat):
        l_mat = len(h_conf_mat)
        return st.mstats.hmean([h_conf_mat[i][i] for i in range(l_mat)])

    dimension_size =len(labels)
    conf_mat=confusion_matrix(y_true=y_true,y_pred=y_pred ,labels=labels)
    if ave_type == AVERAG_TYPE.MATTHEW_GEN.value:
        av_func =st.mstats.gmean
        scalar_op =np.linalg.det
    elif ave_type ==AVERAG_TYPE.F1_GEN.value:
        av_func = st.mstats.hmean
        scalar_op =gen_f1_scalar_op

    G_mat= norm_confusion_mat(conf_mat, av_func, dimension_size)
    return scalar_op(G_mat)
```


### Additional context

I wish to stress that there is a sound mathematical work behind this generalization which is soon to be published . The paper will be gladly provided by either myself or Uri Itai

COMMENT:
I was referring to your comment about this working not being published:

> I wish to stress that there is a sound mathematical work behind this generalization which is soon to be published . The paper will be gladly provided by either myself or Uri Itai

Papers only geometric mean is not enough. We require well-established published references that showcases the proposed method for computing the Matthew coefficient on multi-class problems.

Labels: New Feature, Needs Decision - Include Feature