Talip7/scikit-learn-issues-multilabel huggingface dataset:
Make it easier to overload the `fit_methods` in `check_param_validation`

We introduced `check_param_validation`. This check could be useful to other third-party libraries. However, it will be limited to the fit methods defined in the scikit-learn API.

In imbalanced-learn, we define `fit_resample`. Such a method would not be called the `check`. I am wondering if we could expose the list of the fit methods and make it easy to register a method to be tested.

COMMENT:
ping @jeremiedbb

Labels: Needs Decision - Include Feature, Validation
Make it easier to overload the `fit_methods` in `check_param_validation`

We introduced `check_param_validation`. This check could be useful to other third-party libraries. However, it will be limited to the fit methods defined in the scikit-learn API.

In imbalanced-learn, we define `fit_resample`. Such a method would not be called the `check`. I am wondering if we could expose the list of the fit methods and make it easy to register a method to be tested.

COMMENT:
This is not specific to the check for param_validation. Many checks in ``estimator_checks`` define their own list of methods they want to call. I think this should be solved as part of the huge but necessary refactor of the estimator checks (ref https://github.com/scikit-learn/scikit-learn/issues/16241, https://github.com/scikit-learn/scikit-learn/issues/13969)

Labels: Needs Decision - Include Feature, Validation
Make it easier to overload the `fit_methods` in `check_param_validation`

We introduced `check_param_validation`. This check could be useful to other third-party libraries. However, it will be limited to the fit methods defined in the scikit-learn API.

In imbalanced-learn, we define `fit_resample`. Such a method would not be called the `check`. I am wondering if we could expose the list of the fit methods and make it easy to register a method to be tested.

COMMENT:
Actually, I think that I manage to implement it and it was not a hassle.

Labels: Needs Decision - Include Feature, Validation
drop correlated features as a pipeline step

### Describe the workflow you want to enable


Doing FeatureSelection droping correlated features is standard ml proc that sklearn covers.
But, as i interpret the documentation, sklearn treats the featureSelection based on correlations as a previous step, outside the pipeline.
An in the pipeline, you can only do univarte or iterative featureSelections [docs](https://scikit-learn.org/stable/modules/feature_selection.html#feature-selection-using-selectfrommodel)

I would like to do FeatureSelection based on correlations, as a pipeline step

### Describe your proposed solution

something like 
```py
from sklearn.covariance import MinCovDet_
clf = Pipeline([
  ('feature_selection', SelectFromModel(MinCovDet_())),
  ('classification', RandomForestClassifier())
])
clf.fit(X, y)
```
Where MinCovDet_ ~ MinCovDet but returns the ingested df, so the classification step can do the fit

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

Maybe a `SelectFromCorrelation` wrapper that you can run on top of all the `sklearn.covariance` correlators would be better

### Additional context

_No response_

COMMENT:
Thank you for opening the issue! According to our [triaging docs](https://scikit-learn.org/dev/developers/bug_triaging.html), I am closing this issue because it is a duplicate of https://github.com/scikit-learn/scikit-learn/issues/13405. You are welcome to continue the discussion in #13405.

Labels: New Feature, Needs Triage
drop correlated features as a pipeline step

### Describe the workflow you want to enable


Doing FeatureSelection droping correlated features is standard ml proc that sklearn covers.
But, as i interpret the documentation, sklearn treats the featureSelection based on correlations as a previous step, outside the pipeline.
An in the pipeline, you can only do univarte or iterative featureSelections [docs](https://scikit-learn.org/stable/modules/feature_selection.html#feature-selection-using-selectfrommodel)

I would like to do FeatureSelection based on correlations, as a pipeline step

### Describe your proposed solution

something like 
```py
from sklearn.covariance import MinCovDet_
clf = Pipeline([
  ('feature_selection', SelectFromModel(MinCovDet_())),
  ('classification', RandomForestClassifier())
])
clf.fit(X, y)
```
Where MinCovDet_ ~ MinCovDet but returns the ingested df, so the classification step can do the fit

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

Maybe a `SelectFromCorrelation` wrapper that you can run on top of all the `sklearn.covariance` correlators would be better

### Additional context

_No response_

COMMENT:
oh, searching around didn't found the duplicate.
thanks!

Labels: New Feature, Needs Triage
⚠️ CI failed on Linux_nogil.pylatest_pip_nogil ⚠️

**CI failed on [Linux_nogil.pylatest_pip_nogil](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=49545&view=logs&j=67fbb25f-e417-50be-be55-3b1e9637fce5)** (Dec 02, 2022)
- test_balance_property[74-False-LogisticRegressionCV]

COMMENT:
This might not be related to `nogil` but rather to `global_random_seed=74`. The assertion failure is barely above the tolerance level (`0.35003600108334504 == 0.35 ± 3.5e-05`).

Labels: Bug, Build / CI
⚠️ CI failed on Linux_nogil.pylatest_pip_nogil ⚠️

**CI failed on [Linux_nogil.pylatest_pip_nogil](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=49545&view=logs&j=67fbb25f-e417-50be-be55-3b1e9637fce5)** (Dec 02, 2022)
- test_balance_property[74-False-LogisticRegressionCV]

COMMENT:
I can reproduce on my macos laptop with:

```
SKLEARN_TESTS_GLOBAL_RANDOM_SEED=74 pytest -k"test_balance_property[74-False-LogisticRegressionCV]" sklearn/linear_model/tests/test_common.py
```

so it's independent of the platform and version of Python. I will open a PR to adjust the tolerance and make the test robust to the choice of the seed.

Labels: Bug, Build / CI
check_array does not gracefully fail with pd.NA

When a NumPy array or a pandas series contains `pd.NA`, it will not gracefully fail.

```python
In [1]: import pandas as pd

In [2]: s = pd.Series([1, 2, None], dtype="Int64")

In [3]: from sklearn.utils.validation import check_array

In [4]: check_array(s, ensure_2d=False)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [4], line 1
----> 1 check_array(s, ensure_2d=False)

File ~/Documents/packages/scikit-learn/sklearn/utils/validation.py:912, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)
    906         raise ValueError(
    907             "Found array with dim %d. %s expected <= 2."
    908             % (array.ndim, estimator_name)
    909         )
    911     if force_all_finite:
--> 912         _assert_all_finite(
    913             array,
    914             input_name=input_name,
    915             estimator_name=estimator_name,
    916             allow_nan=force_all_finite == "allow-nan",
    917         )
    919 if ensure_min_samples > 0:
    920     n_samples = _num_samples(array)

File ~/Documents/packages/scikit-learn/sklearn/utils/validation.py:110, in _assert_all_finite(X, allow_nan, msg_dtype, estimator_name, input_name)
    108 # for object dtype data, we only check for NaNs (GH-13254)
    109 if X.dtype == np.dtype("object") and not allow_nan:
--> 110     if _object_dtype_isnan(X).any():
    111         raise ValueError("Input contains NaN")
    113 # We need only consider float arrays, hence can early return for all else.

AttributeError: 'bool' object has no attribute 'any'
```

The reason is that we `_object_dtype_isnan` intend the following:

```python
In [7]: s.to_numpy() != s.to_numpy()
<ipython-input-7-e1263eaa78fa>:1: DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
  s.to_numpy() != s.to_numpy()
Out[7]: True
```

that returns a single boolean because if fails when comparing `pd.NA`:

```python
In [5]: bool(pd.NA == pd.NA)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [5], line 1
----> 1 bool(pd.NA == pd.NA)

File ~/mambaforge/envs/dev/lib/python3.10/site-packages/pandas/_libs/missing.pyx:382, in pandas._libs.missing.NAType.__bool__()

TypeError: boolean value of NA is ambiguous
```

We should probably change the code to handle this case.

COMMENT:
Is this behavior really desirable  ?
```py
>>> pd.NA == pd.NA
<NA>
```
I'd expect the result of `==` to be a bool

Labels: Bug
check_array does not gracefully fail with pd.NA

When a NumPy array or a pandas series contains `pd.NA`, it will not gracefully fail.

```python
In [1]: import pandas as pd

In [2]: s = pd.Series([1, 2, None], dtype="Int64")

In [3]: from sklearn.utils.validation import check_array

In [4]: check_array(s, ensure_2d=False)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [4], line 1
----> 1 check_array(s, ensure_2d=False)

File ~/Documents/packages/scikit-learn/sklearn/utils/validation.py:912, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)
    906         raise ValueError(
    907             "Found array with dim %d. %s expected <= 2."
    908             % (array.ndim, estimator_name)
    909         )
    911     if force_all_finite:
--> 912         _assert_all_finite(
    913             array,
    914             input_name=input_name,
    915             estimator_name=estimator_name,
    916             allow_nan=force_all_finite == "allow-nan",
    917         )
    919 if ensure_min_samples > 0:
    920     n_samples = _num_samples(array)

File ~/Documents/packages/scikit-learn/sklearn/utils/validation.py:110, in _assert_all_finite(X, allow_nan, msg_dtype, estimator_name, input_name)
    108 # for object dtype data, we only check for NaNs (GH-13254)
    109 if X.dtype == np.dtype("object") and not allow_nan:
--> 110     if _object_dtype_isnan(X).any():
    111         raise ValueError("Input contains NaN")
    113 # We need only consider float arrays, hence can early return for all else.

AttributeError: 'bool' object has no attribute 'any'
```

The reason is that we `_object_dtype_isnan` intend the following:

```python
In [7]: s.to_numpy() != s.to_numpy()
<ipython-input-7-e1263eaa78fa>:1: DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
  s.to_numpy() != s.to_numpy()
Out[7]: True
```

that returns a single boolean because if fails when comparing `pd.NA`:

```python
In [5]: bool(pd.NA == pd.NA)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [5], line 1
----> 1 bool(pd.NA == pd.NA)

File ~/mambaforge/envs/dev/lib/python3.10/site-packages/pandas/_libs/missing.pyx:382, in pandas._libs.missing.NAType.__bool__()

TypeError: boolean value of NA is ambiguous
```

We should probably change the code to handle this case.

COMMENT:
Yes but no : https://pandas.pydata.org/docs/user_guide/missing_data.html#propagation-in-arithmetic-and-comparison-operations

> In equality and comparison operations, pd.NA also propagates. This deviates from the behaviour of np.nan, where comparisons with np.nan always return False.

Labels: Bug
Wrong description for the `n_jobs` in mean_shift docs

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/25059

<div type='discussions-op-text'>

<sup>Originally posted by **gittar** November 28, 2022</sup>
Should in these doc fragments the variable `n_init` be replaced by `n_jobs`? It appears nowhere else in the codefile.
https://github.com/scikit-learn/scikit-learn/blob/f3f51f9b611bf873bd5836748647221480071a87/sklearn/cluster/_mean_shift.py#L165-L167

https://github.com/scikit-learn/scikit-learn/blob/f3f51f9b611bf873bd5836748647221480071a87/sklearn/cluster/_mean_shift.py#L301-L303
</div>

COMMENT:
It looks like it was copy-pasted from KMeans. We need to change the description to explain which task is run in parallel in MeanShift

Labels: Documentation, help wanted
Wrong description for the `n_jobs` in mean_shift docs

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/25059

<div type='discussions-op-text'>

<sup>Originally posted by **gittar** November 28, 2022</sup>
Should in these doc fragments the variable `n_init` be replaced by `n_jobs`? It appears nowhere else in the codefile.
https://github.com/scikit-learn/scikit-learn/blob/f3f51f9b611bf873bd5836748647221480071a87/sklearn/cluster/_mean_shift.py#L165-L167

https://github.com/scikit-learn/scikit-learn/blob/f3f51f9b611bf873bd5836748647221480071a87/sklearn/cluster/_mean_shift.py#L301-L303
</div>

COMMENT:
Done the changes

Labels: Documentation, help wanted
Output is missing in this particular codeblock in  "sklearn.compose.ColumnTransformer"

### Describe the issue linked to the documentation

At the last line of the code  that is X_trans = ct.fit_transform(X) the output(X_trans variable)  is not specified which is confusing.

This particular code block is present in
` https://scikit-learn.org/stable/modules/generated/sklearn.compose.ColumnTransformer.html`

<img width="926" alt="Screenshot 2022-11-30 at 10 37 12 AM" src="https://user-images.githubusercontent.com/111889155/204712549-1af016a2-8aa1-4e39-9f3a-9caea23ac538.png">


### Suggest a potential alternative/fix

_No response_

COMMENT:
I"m not quite sure I understand what you mean. I think what you are saying is that the value of `ct.fit_transform(X)` is not shown. Is this the change you are looking for?

Labels: Documentation
Output is missing in this particular codeblock in  "sklearn.compose.ColumnTransformer"

### Describe the issue linked to the documentation

At the last line of the code  that is X_trans = ct.fit_transform(X) the output(X_trans variable)  is not specified which is confusing.

This particular code block is present in
` https://scikit-learn.org/stable/modules/generated/sklearn.compose.ColumnTransformer.html`

<img width="926" alt="Screenshot 2022-11-30 at 10 37 12 AM" src="https://user-images.githubusercontent.com/111889155/204712549-1af016a2-8aa1-4e39-9f3a-9caea23ac538.png">


### Suggest a potential alternative/fix

_No response_

COMMENT:
I assume that you expect the following:

```python
X_trans = ct.fit_transform(X)
X_trans
<3x1048577 sparse matrix of type '<class 'numpy.float64'>'
	with 29 stored elements in Compressed Sparse Row format>
```
Not sure that we really want to show the output.
I am fine to keep the documentation as-is.

Labels: Documentation
Output is missing in this particular codeblock in  "sklearn.compose.ColumnTransformer"

### Describe the issue linked to the documentation

At the last line of the code  that is X_trans = ct.fit_transform(X) the output(X_trans variable)  is not specified which is confusing.

This particular code block is present in
` https://scikit-learn.org/stable/modules/generated/sklearn.compose.ColumnTransformer.html`

<img width="926" alt="Screenshot 2022-11-30 at 10 37 12 AM" src="https://user-images.githubusercontent.com/111889155/204712549-1af016a2-8aa1-4e39-9f3a-9caea23ac538.png">


### Suggest a potential alternative/fix

_No response_

COMMENT:
> I"m not quite sure I understand what you mean. I think what you are saying is that the value of `ct.fit_transform(X)` is not shown. Is this the change you are looking for?

yes that's the change I am looking for

Labels: Documentation
Output is missing in this particular codeblock in  "sklearn.compose.ColumnTransformer"

### Describe the issue linked to the documentation

At the last line of the code  that is X_trans = ct.fit_transform(X) the output(X_trans variable)  is not specified which is confusing.

This particular code block is present in
` https://scikit-learn.org/stable/modules/generated/sklearn.compose.ColumnTransformer.html`

<img width="926" alt="Screenshot 2022-11-30 at 10 37 12 AM" src="https://user-images.githubusercontent.com/111889155/204712549-1af016a2-8aa1-4e39-9f3a-9caea23ac538.png">


### Suggest a potential alternative/fix

_No response_

COMMENT:
Given the output would be what Guillaume showed in his comment I don't see what showing it in the example would solve. You can't see the actual values, just an obscure comment that IMHO is more confusing than helpful.

So I think we should close this issue without updating the example.

Labels: Documentation
⚠️ CI failed on Linux_Nightly_PyPy.pypy3 ⚠️

**CI failed on [Linux_Nightly_PyPy.pypy3](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=49433&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66)** (Nov 30, 2022)
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=49545&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66) on Dec 02, 2022

Labels: Build / CI
⚠️ CI failed on Linux_Nightly_PyPy.pypy3 ⚠️

**CI failed on [Linux_Nightly_PyPy.pypy3](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=49433&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66)** (Nov 30, 2022)
Unable to find junit file. Please see link for details.

COMMENT:
Nice.

Labels: Build / CI
logistic regression - Setting penalty equal to L2 regularization when user has specified penalty as none

Hello - I believe that there is a mistake here. When a user sets penalty to 'none' or None, the penalty is then set to l2 with absolutely no indication to the user... with this implementation, there is no way we are able to specify not to apply regularization even though the documentation explicitly says that the default solver lbfgs should be able to support no regularization...
![image](https://user-images.githubusercontent.com/51860409/204638202-be6852d6-1504-4430-916b-fff81d7891a7.png)

https://github.com/scikit-learn/scikit-learn/blob/808c32df07427b2df937899d7b1a445620ae7676/sklearn/linear_model/_logistic.py#L1186

COMMENT:
In the solver, `C_` is the inverse scalar which mediates the regularization, i.e. `Final Loss = Loss + (1/C_) * L2`. In this case we have `C_ = np.inf` so `1/C_ = 0.0` and it is equivalent to unregularized loss.

For reference, eventually `C_` is used as `C` in the following portion of code: https://github.com/scikit-learn/scikit-learn/blob/808c32df07427b2df937899d7b1a445620ae7676/sklearn/linear_model/_logistic.py#L444-L446

Closing for now. Please let me know if you have further questions or concerns :)

Labels: Needs Triage
logistic regression - Setting penalty equal to L2 regularization when user has specified penalty as none

Hello - I believe that there is a mistake here. When a user sets penalty to 'none' or None, the penalty is then set to l2 with absolutely no indication to the user... with this implementation, there is no way we are able to specify not to apply regularization even though the documentation explicitly says that the default solver lbfgs should be able to support no regularization...
![image](https://user-images.githubusercontent.com/51860409/204638202-be6852d6-1504-4430-916b-fff81d7891a7.png)

https://github.com/scikit-learn/scikit-learn/blob/808c32df07427b2df937899d7b1a445620ae7676/sklearn/linear_model/_logistic.py#L1186

COMMENT:
thank you!

Labels: Needs Triage
RFC Enabling auto-merge builtin Github functionality

The main advantage would be to be able to say on a per-PR basis "this PR can be merged when CI is green". See the [doc](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request) for more details. cc @scikit-learn/core-devs @scikit-learn/contributor-experience-team for visibility.

Currently we need to remember to come back in one hour and we sometimes forget. As a maintainer with many different things to track, it would be very nice to have this sense of quicker completion and the peace of mind of not having to remember to come back to merge the PR.

Here is a screenshot from sphinx-gallery which has set this up:
![image](https://user-images.githubusercontent.com/1680079/204514285-836bca8f-163e-4f07-9a84-b13441b8ee6d.png)

You can see this is a per-PR thing ("Enable automerge" button) and there is even a way to bypass branch protection, which can be nice in some rare cases (for example we know for a fact that the CI error is not related to the PR).

Things we would need to do:
- [ ] set-up branch [branch protection rules](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule)
  + [ ] define required checks: probably azure + github doc build, maybe others. We probably want to leave aside other more noisy checks like codecov?
  + [ ] require 1 approval rather than 2 (to allow DOC PRs to be merged with only one approval)
- [ ] set-up [auto-merge](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-auto-merge-for-pull-requests-in-your-repository)
  + [ ] make sure we check the require required checks (Thomas' comment at the meeting)
  + [ ] reset auto-merge when a commit is pushed after auto-merge is set, just to be on the safe side. This [link](https://github.blog/changelog/2021-03-22-updated-pull-request-auto-merge-behavior-for-users-without-write-access/) says that it is done automatically, unclear whether this is the same thing as "Dismiss stale pull request approvals when new commits are pushed" setting in branch protection rules.

Other items from discussions at the meeting:
- Q: does a human have to click "auto merge" on a PR for it to happen, or does it automatically happen for all PRs that match the approval requirements?
- A: a per PR manual action is required to allow automerge, see screenshot above
- Q: is "merge when CI is green" functionality of "[Refined GitHub](https://github.com/refined-github/refined-github)" a solution?
- A: you need to keep the tab open for it to work, and in my limited experience it does not work reliably. Also it is not public information that the PR will be merged when CI is green.

COMMENT:
You get to chose your commit message after clicking "Enable auto-merge" and before clicking "Confirm auto-merge":

![image](https://user-images.githubusercontent.com/1680079/204578973-2eef8018-f2ca-438c-a72d-03173d032b68.png)

Labels: RFC