Talip7/scikit-learn-issues-multilabel huggingface dataset:
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
Fantastic! Great to know that my idea may come into fruition :)

Looking forward to seeing it. @PredictiveManish, since you've already start, go ahead and let know if you need any help.

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
Any update on this? I can open a pull request to add the feature later this week if you have not worked on it yet.

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
Hi,

I am looking for an issue in order to make my first contribution to the project and this one seems quite easy to work on for a first issue, can I work on this ? I would be able to propose something and make a PR by the end of the week maximum

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
Thank you, @alifa98 and @PredictiveManish for offering. @paulAdrienMarie and I went ahead with making it.

Thank you @jeremiedbb for supporting this idea - we made the PR with minimal code changes to ensure that the existing code does not break. Kindly give your feedback: https://github.com/scikit-learn/scikit-learn/pull/30463

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
Okay great no worries ! 

I tried to reproduce by implementing the modifications you've made but I have 53 tests that don't pass when running `pytest -v sklearn/linear_model/tests/test_coordinate_descent.py`. When the tests don't pass it is because the ElasticNetCV and MultiElasticNetCV doesn't have an attribut refit. 

Do you have the same errors ?

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
Yes, you are right, @paulAdrienMarie. I seem to have missed it! Thank you for pointing out.

Since you have found it, I would like you to get the credit :) Please add the following lines of code to the classes' definitions in this PR: https://github.com/scikit-learn/scikit-learn/pull/30463.

```python
refit=True # init kwargs
self.refit = refit # init() definition
```

If you are unable to do so, kindly let me know and I will gladly work with you.

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
Great I am taking care of it ! Thank you very much I'll let you know when I am done :)

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
@jeremiedbb , LogisticRegressionCV already has `refit` attribute.

Just want to confirm this refit is doing the same as what he have discussed, right?:

```
refit bool, default=True
If set to True, the scores are averaged across all folds, and the coefs and the C that corresponds to the best score is taken, and a final refit is done using these parameters. Otherwise the coefs, intercepts and C that correspond to the best scores across folds are averaged.
```

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
`ValueError: ('Unexpected parameters in params', dict_keys(['refit']))` I keep on getting this error when running `pytest sklearn/linear_model/tests/test_coordinate_descent.py`. Do you get the same when running the tests, or can you help me solving it ?

Labels: Enhancement
ENH Allow disabling refitting of cross-validation estimators

### Discussed in https://github.com/scikit-learn/scikit-learn/discussions/30233

<div type='discussions-op-text'>

<sup>Originally posted by **AhmedThahir** November  7, 2024</sup>
Feature request: Allow disable refitting of cross-validation estimators (such as LassoCV, RidgeCV) on the full training set after finding the best hyperparameters?

Sometimes I only want the optimal hyperparameter and do not want to waste resources on refitting. This is especially important for large datasets. </div>

As @alifa98 has highlighted, this is the relevant code block.
https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/linear_model/_coordinate_descent.py#L1815

User should be allowed to toggle this behavior.

COMMENT:
just commited my changes to your PR, please let me know if you find out where the error comes from :)

Labels: Enhancement
Is there any interest to provide SymmetricNMF

### Describe the workflow you want to enable

Hi! I have a [prototype implementation of Symmetric NMF](https://github.com/kushalkolar/symmetric-nmf) that I [ported from matlab](https://github.com/dakuang/symnmf). There are 2 main papers on it, the oldest one from 2012 has ~500 citations: https://scholar.google.com/scholar?hl=en&as_sdt=0%2C33&q=Symmetric+Nonnegative+Matrix+Factorization&btnG= 

Symmetric NMF is useful for clustering graphs and allows for soft clustering where a node may belong to multiple clusters. Example, here node 2 has strong membership to cluster 1 and partial membership to cluster 2. It can be seen as an alternative to Gaussian Mixture Models for soft clustering problems, however SymmNMF works directly with an affinity matrix whereas soft clustering with a GMM would typically require projecting the affinity matrix to some low dimensional space.

![Figure_1](https://github.com/user-attachments/assets/084e0102-c0b6-41f9-bc45-f66691ec5428)


### Describe your proposed solution

Merge this implementation into sklearn once I've tested that it's robust and reliable: https://github.com/kushalkolar/symmetric-nmf 


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

_No response_

### Additional context

_No response_

COMMENT:
No strong opinion either way. I had never heard about it, but what you describe above makes sense. Does it work on large graphs with affinity matrices stored in a sparse matrix (with truncated low affinity values)?

Labels: New Feature, Needs Decision - Include Feature
Is there any interest to provide SymmetricNMF

### Describe the workflow you want to enable

Hi! I have a [prototype implementation of Symmetric NMF](https://github.com/kushalkolar/symmetric-nmf) that I [ported from matlab](https://github.com/dakuang/symnmf). There are 2 main papers on it, the oldest one from 2012 has ~500 citations: https://scholar.google.com/scholar?hl=en&as_sdt=0%2C33&q=Symmetric+Nonnegative+Matrix+Factorization&btnG= 

Symmetric NMF is useful for clustering graphs and allows for soft clustering where a node may belong to multiple clusters. Example, here node 2 has strong membership to cluster 1 and partial membership to cluster 2. It can be seen as an alternative to Gaussian Mixture Models for soft clustering problems, however SymmNMF works directly with an affinity matrix whereas soft clustering with a GMM would typically require projecting the affinity matrix to some low dimensional space.

![Figure_1](https://github.com/user-attachments/assets/084e0102-c0b6-41f9-bc45-f66691ec5428)


### Describe your proposed solution

Merge this implementation into sklearn once I've tested that it's robust and reliable: https://github.com/kushalkolar/symmetric-nmf 


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

_No response_

### Additional context

_No response_

COMMENT:
Alternatively, it would be possible to make it a scikit-learn-contrib project to make it more discoverable.

Labels: New Feature, Needs Decision - Include Feature
CI Use CIBW_ENABLE rather than CIBW_FREE_THREADED_SUPPORT in wheels builder

It seems like this is about CIBW_FREETHREADED_SUPPORT and CIBW_PRERELEASE_PYTHONS. There may be some complications for CIBW_PRERELEASE_PYTHONS which we are using for Windows minimal docker image.

> Added a new CIBW_ENABLE/enable feature that replaces CIBW_FREETHREADED_SUPPORT/free-threaded-support and CIBW_PRERELEASE_PYTHONS with a system that supports both. In cibuildwheel 3, this will also include a PyPy setting and the deprecated options will be removed. ([#2048](https://redirect.github.com/pypa/cibuildwheel/issues/2048))

Is it relevant for us @lesteve ?

_Originally posted by @jeremiedbb in https://github.com/scikit-learn/scikit-learn/pull/30379#pullrequestreview-2472614735_

COMMENT:
We have switched to CIBW_ENABLE a while ago, let's close this one!

Labels: Build / CI
CI Replace pytorch conda channel in CI lock-files

After a quick look, it seems like the only place we are using the pytorch channel is for the CUDA CI, cc @betatim.

The easiest thing to try would be to use the conda-forge pytorch-gpu package?

See https://github.com/pytorch/pytorch/issues/138506 for more details. the main thing is:

> 2.5 will be the last release of PyTorch that will be published to the [pytorch](https://anaconda.org/pytorch) channel on Anaconda

So for now, it seems like nothing will break, we will keep using the PyTorch `2.5.*` release, which for now is the latest release (until PyTorch 2.6 is released, not sure about the timeline).

COMMENT:
> The easiest thing to try would be to use the conda-forge pytorch-gpu package?

I think so too. Or we could switch to using the wheel?

Labels: Build / CI
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
ping @adrinjalali @ogrisel @jeremiedbb @lesteve

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
`validate_data` has a `do not check_array` param, that should be basically running these instead.

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
You mean `skip_check_array` :). Indeed, new in 1.6.

I would therefore only advocate for improving the documentation of those two functions such that they mention to use `validate_data` and point to this parameter.

We probably want to update our own code base as well because we don't follow this pattern for the `FunctionTransformer` as far I remember:

https://github.com/scikit-learn/scikit-learn/blob/fba028b07ed2b4e52dd3719dad0d990837bde28c/sklearn/preprocessing/_function_transformer.py#L181-L190

We could make a small search in the project to check if the call to the private functions is legitimate or not.

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
Hi! I'd like to work on this as my first contribution. Let me know if it's okay to proceed.

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
@shamitbilla this is not a good first contribution. Once you're familiar with the codebase, you can tackle such an issue. Sadly there's quite a bit of a difference between "easy" and "good first issue" 😉

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
Oh okay, I will look for the good first issues then. Thanks for the guidance!

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
/take

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
To contributors: If you plan on working on this issue, please leave a comment as how you plan to solve the issue. We don't really have / care about assigning issues to people.

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
PR: https://github.com/scikit-learn/scikit-learn/pull/31585

Hi! I've previously contributed to scikit-learn and would like to work on this issue.

I’ll:
- Search the codebase for all uses of `_check_n_features` and `_check_feature_names`
- Improve the docstrings to clearly reference `validate_data(skip_check_array=True)`
- Review if internal usages (like in `FunctionTransformer`) align with this pattern
- Avoid making the functions public unless explicitly requested again

Let me know if it’s okay to proceed!

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
That sounds good @VirenPassi

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
@glemaitre @adrinjalali I've searched the entire project and the table below summarizes my findings. 

Do you agree with my recommendations? I believe methods that use both `_check_feature_names` and `_check_n_features` should be replaced by `validate_data(skip_check_array=True)`.

Here is the grep command I ran to determine relevant files:

```
grep -r "_check_feature_names\|_check_n_features" sklearn/   | grep -v "_check_feature_names_in"   | grep -v "/test[^/]*"   | grep -v "/validation\.py:" | grep -v "/_pd_utils\.py:"
```

Here's the summary table:

| File | Method | `_check_feature_names` | `_check_n_features` | Recommendation |
|------|---------|---------------|----------------|--------|
| sklearn/tree/_classes.py | `_validate_X_predict` | N | *Y* | Remain as-is |
| sklearn/compose/_column_transformer.py | `fit_transform` | *Y* | *Y* | Replace with `validate_data(skip_check_array=True)`|
| sklearn/impute/_base.py | `_fit` | N | *Y* | Remain as-is |
| sklearn/feature_selection/_from_model.py | `fit` | *Y* | N | Remain as-is |
| sklearn/feature_selection/_from_model.py | `partial_fit` | *Y* | N | Remain as-is |
| sklearn/inspection/_partial_dependence.py | `partial_dependence` | *Y* | N | Remain as-is |
| sklearn/inspection/_plot/partial_dependence.py | `from_estimator` | *Y* | N | Remain as-is |
| sklearn/naive_bayes.py | `_joint_log_likelihood` | N | *Y* | Remain as-is |
| sklearn/preprocessing/_encoders.py | `_fit` | *Y* | *Y* | Replace with `validate_data(skip_check_array=True)` |

Labels: Easy, Documentation, help wanted
Make `_check_n_features` and `_check_feature_names` public

Since we are moving, `_check_n_features` and `_check_feature_names` into a new module, I'm wondering if we should make them public as well.

I can imagine some people that don't want to use `validate_data` but still want to set `self.n_features_in_` or `self.feature_names_in_`.

COMMENT:
@j-hendricks thanks for the analysis. Feel free to open a PR to replace those usages with `validate_data`.

For the other cases, I really wonder if a refactoring can make the code cleaner and simply use `validate_data` as well.

Labels: Easy, Documentation, help wanted