Talip7/scikit-learn-issues-multilabel huggingface dataset:
⚠️ CI failed on Wheel builder (last failure: Mar 12, 2025) ⚠️

**CI failed on [Wheel builder](https://github.com/scikit-learn/scikit-learn/actions/runs/13803264391)** (Mar 12, 2025)

COMMENT:
Seems like an issue with Cython and free-threaded. We are using the Cython nightly wheel so this may have been introduced recently. [March 11 build log](https://github.com/scikit-learn/scikit-learn/actions/runs/13779920279) ✅, [March 12 build log](https://github.com/scikit-learn/scikit-learn/actions/runs/13803264391) ❌.

```
  + python -c 'import sklearn; sklearn.show_versions()'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
      import sklearn; sklearn.show_versions()
      ^^^^^^^^^^^^^^
    File "/tmp/tmp.TCxJlXkthf/venv/lib/python3.13t/site-packages/sklearn/__init__.py", line 73, in <module>
      from .base import clone  # noqa: E402
      ^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/tmp.TCxJlXkthf/venv/lib/python3.13t/site-packages/sklearn/base.py", line 19, in <module>
      from .utils._estimator_html_repr import _HTMLDocumentationLinkMixin, estimator_html_repr
    File "/tmp/tmp.TCxJlXkthf/venv/lib/python3.13t/site-packages/sklearn/utils/__init__.py", line 15, in <module>
      from ._chunking import gen_batches, gen_even_slices
    File "/tmp/tmp.TCxJlXkthf/venv/lib/python3.13t/site-packages/sklearn/utils/_chunking.py", line 11, in <module>
      from ._param_validation import Interval, validate_params
    File "/tmp/tmp.TCxJlXkthf/venv/lib/python3.13t/site-packages/sklearn/utils/_param_validation.py", line 14, in <module>
      from scipy.sparse import csr_matrix, issparse
    File "/tmp/tmp.TCxJlXkthf/venv/lib/python3.13t/site-packages/scipy/sparse/__init__.py", line 306, in <module>
      from ._lil import *
    File "/tmp/tmp.TCxJlXkthf/venv/lib/python3.13t/site-packages/scipy/sparse/_lil.py", line 17, in <module>
      from . import _csparsetools
  TypeError: type '_cython_3_1_0b0.fused_cython_function' is not dynamically allocated but its base type '_cython_3_1_0b0.cython_function_or_method' is dynamically allocated
```

Labels: Needs Triage
⚠️ CI failed on Wheel builder (last failure: Mar 12, 2025) ⚠️

**CI failed on [Wheel builder](https://github.com/scikit-learn/scikit-learn/actions/runs/13803264391)** (Mar 12, 2025)

COMMENT:
I can not reproduce this locally for some reason, let's wait and see if it happens again tomorrow ...

It may be a scipy dev wheel issue actually, since the error happens when importing `scipy.sparse`

Labels: Needs Triage
⚠️ CI failed on Wheel builder (last failure: Mar 12, 2025) ⚠️

**CI failed on [Wheel builder](https://github.com/scikit-learn/scikit-learn/actions/runs/13803264391)** (Mar 12, 2025)

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://github.com/scikit-learn/scikit-learn/actions/runs/13826650719) on Mar 13, 2025

Labels: Needs Triage
auto clusters selection of n_clusters with elbow method

### Describe the workflow you want to enable

In, sklearn.cluster the KMeans algorithm.
the feature suggestion is to add the elbow method cluster selection
with n_cluster="auto"

calculates the best no of cluster based on mse 
add trains the models based on the return output of auto_cluster_selection()
with auto as keyword in KMeans

### Describe your proposed solution

to create a private method in the KMeans to calculate the no of best clusters automatically by taking the n_clusters="auto"

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

_No response_

### Additional context

_No response_

COMMENT:
Thanks for the issue! Honestly this is unlikely to be a high priority for us in the foreseeable future, so I am going to close this one.

See for example https://github.com/scikit-learn/scikit-learn/pull/6948 where this kind of things were discussed.

Labels: New Feature, Needs Triage
Allow for multiclass cost matrix in FixedThresholdClassifier and TunedThresholdClassifierCV

### Describe the workflow you want to enable

With #26120, we got `FixedThresholdClassifier` and `TunedThresholdClassifierCV` but only for binary classification. The next logical step would be to extend it to the multiclass setup.

### Describe your proposed solution

For `FixedThresholdClassifier`, one could allow for a cost matrix instead of a single threshold.

`TunedThresholdClassifierCV` seems straight forward (or I'm missing something).

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

_No response_

### Additional context

_No response_

COMMENT:
Hi! I’d like to take this issue my plan for extending FixedThresholdClassifier to multiclass is
(1) Add a cost_matrix parameter (n_classes x n_classes) to handle multiclass scenarios, where the predicted class minimizes the expected cost.
(2) For binary, keep the current threshold parameter for backward compatibility.
(3) In predict, if cost_matrix is set, compute expected costs via np.dot(proba, cost_matrix.T) and pick the class with the lowest cost.
(4) Validate that cost_matrix shape matches n_classes.

Is this the right direction? Any feedback or suggestions before I proceed further?

Thanks!

Labels: New Feature, module:model_selection, module:multiclass
Allow for multiclass cost matrix in FixedThresholdClassifier and TunedThresholdClassifierCV

### Describe the workflow you want to enable

With #26120, we got `FixedThresholdClassifier` and `TunedThresholdClassifierCV` but only for binary classification. The next logical step would be to extend it to the multiclass setup.

### Describe your proposed solution

For `FixedThresholdClassifier`, one could allow for a cost matrix instead of a single threshold.

`TunedThresholdClassifierCV` seems straight forward (or I'm missing something).

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

_No response_

### Additional context

_No response_

COMMENT:
Anything new here? Would love to see this feature 👍

Labels: New Feature, module:model_selection, module:multiclass
DOC better visibility in navigation of metadata routing

The section about [metadata_routing](https://scikit-learn.org/stable/metadata_routing.html) in the [user guide](https://scikit-learn.org/stable/user_guide.html) is hard to find, in particular because there is no entry in the navigation bar, see

<img width="1104" alt="Image" src="https://github.com/user-attachments/assets/014c9d80-1cb3-4e7c-9e3d-34333bf8e87d" />

COMMENT:
Back when we merged metadata routing infra, people were a bit worried about exposing the feature in any prominent way.

I think these days we can safely move it to a more visible place, since it's used quite a bit.

Labels: Documentation, Metadata Routing
DOC better visibility in navigation of metadata routing

The section about [metadata_routing](https://scikit-learn.org/stable/metadata_routing.html) in the [user guide](https://scikit-learn.org/stable/user_guide.html) is hard to find, in particular because there is no entry in the navigation bar, see

<img width="1104" alt="Image" src="https://github.com/user-attachments/assets/014c9d80-1cb3-4e7c-9e3d-34333bf8e87d" />

COMMENT:
I can take care of that.

Labels: Documentation, Metadata Routing
⚠️ CI failed on Linux_free_threaded.pylatest_free_threaded (last failure: Mar 10, 2025) ⚠️

**CI is still failing on [Linux_free_threaded.pylatest_free_threaded](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=74605&view=logs&j=c10228e9-6cf7-5c29-593f-d74f893ca1bd)** (Mar 10, 2025)
- test_multiclass_plot_max_class_cmap_kwarg

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=74627&view=logs&j=c10228e9-6cf7-5c29-593f-d74f893ca1bd) on Mar 11, 2025

Labels: Needs Triage
⚠️ CI failed on Linux_Nightly.pylatest_pip_scipy_dev (last failure: Mar 10, 2025) ⚠️

**CI is still failing on [Linux_Nightly.pylatest_pip_scipy_dev](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=74605&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf)** (Mar 10, 2025)
- test_multiclass_plot_max_class_cmap_kwarg

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=74627&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf) on Mar 11, 2025

Labels: Needs Triage
Request: base class with HTML repr but without being an 'Estimator'

### Describe the workflow you want to enable

Creating third-party packages that offer objects that are meant to be passed to estimators, but which aren't estimators themselves.

### Describe your proposed solution

Would be nice if there could be some class similar to `BaseEstimator` that would offer pretty printing, HTML representations, and so on; but without needing to be an estimator (e.g. without having metadata routing and similar).

This could be used for example as a base class for objects that are meant to be passed as constructor arguments to actual estimators, and which are thus desirable to show with a pretty-printed form when visualizing estimators. For example, something like parameterizable probability distributions offered as objects in third-party packages that are meant to be passed to estimators from said third-party packages.

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

_No response_

### Additional context

_No response_

COMMENT:
Right now, one could almost have some of to utils with the following import:

```python
from .utils._estimator_html_repr import _HTMLDocumentationLinkMixin, estimator_html_repr
```

They are kind of private but they could be part of the dev API. They could be potentially consolidated into a mixin but having the function is already helpful.

Labels: New Feature
Request: base class with HTML repr but without being an 'Estimator'

### Describe the workflow you want to enable

Creating third-party packages that offer objects that are meant to be passed to estimators, but which aren't estimators themselves.

### Describe your proposed solution

Would be nice if there could be some class similar to `BaseEstimator` that would offer pretty printing, HTML representations, and so on; but without needing to be an estimator (e.g. without having metadata routing and similar).

This could be used for example as a base class for objects that are meant to be passed as constructor arguments to actual estimators, and which are thus desirable to show with a pretty-printed form when visualizing estimators. For example, something like parameterizable probability distributions offered as objects in third-party packages that are meant to be passed to estimators from said third-party packages.

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

_No response_

### Additional context

_No response_

COMMENT:
I think that we started to support this use case with the following mixin:

https://github.com/scikit-learn/scikit-learn/blob/d4d4af8c471c60d183d0cb67e14e6434b0ebb9fb/sklearn/utils/_repr_html/base.py#L118-L146

@david-cortes Do you think that it answers your need?

Labels: New Feature
Request: base class with HTML repr but without being an 'Estimator'

### Describe the workflow you want to enable

Creating third-party packages that offer objects that are meant to be passed to estimators, but which aren't estimators themselves.

### Describe your proposed solution

Would be nice if there could be some class similar to `BaseEstimator` that would offer pretty printing, HTML representations, and so on; but without needing to be an estimator (e.g. without having metadata routing and similar).

This could be used for example as a base class for objects that are meant to be passed as constructor arguments to actual estimators, and which are thus desirable to show with a pretty-printed form when visualizing estimators. For example, something like parameterizable probability distributions offered as objects in third-party packages that are meant to be passed to estimators from said third-party packages.

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

_No response_

### Additional context

_No response_

COMMENT:
> [@david-cortes](https://github.com/david-cortes) Do you think that it answers your need?

Not quite - that class requires implementing a function to generate the HTML representation if I'm understanding it correctly.

What I had in mind is some class that would automatically create the same kind of HTML representation and pretty-printing as `BaseEstimator`, but without inheriting the other methods that are expected from estimators nor expecting 'fit'/'transform'/etc.

Labels: New Feature
Request: base class with HTML repr but without being an 'Estimator'

### Describe the workflow you want to enable

Creating third-party packages that offer objects that are meant to be passed to estimators, but which aren't estimators themselves.

### Describe your proposed solution

Would be nice if there could be some class similar to `BaseEstimator` that would offer pretty printing, HTML representations, and so on; but without needing to be an estimator (e.g. without having metadata routing and similar).

This could be used for example as a base class for objects that are meant to be passed as constructor arguments to actual estimators, and which are thus desirable to show with a pretty-printed form when visualizing estimators. For example, something like parameterizable probability distributions offered as objects in third-party packages that are meant to be passed to estimators from said third-party packages.

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

_No response_

### Additional context

_No response_

COMMENT:
But we also provide the function that you want that is `estimator_html_repr`.

```python
from sklearn.utils._repr_html.base import ReprHTMLMixin
from sklearn.utils._repr_html.estimator import estimator_html_repr

class Estimator(ReprHTMLMixin):
    _html_repr = estimator_html_repr
```

The fact to be able to inject any function means that you can add you own HTML repr if you don't want to go with the `estimator_html_repr`. For us, it is the flexibility to inject the HTML repr for parameters for instance.

Labels: New Feature
Request: base class with HTML repr but without being an 'Estimator'

### Describe the workflow you want to enable

Creating third-party packages that offer objects that are meant to be passed to estimators, but which aren't estimators themselves.

### Describe your proposed solution

Would be nice if there could be some class similar to `BaseEstimator` that would offer pretty printing, HTML representations, and so on; but without needing to be an estimator (e.g. without having metadata routing and similar).

This could be used for example as a base class for objects that are meant to be passed as constructor arguments to actual estimators, and which are thus desirable to show with a pretty-printed form when visualizing estimators. For example, something like parameterizable probability distributions offered as objects in third-party packages that are meant to be passed to estimators from said third-party packages.

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

_No response_

### Additional context

_No response_

COMMENT:
But that doesn't quite render it the same way:

![Image](https://github.com/user-attachments/assets/6abb6221-6790-470c-b378-bf6663559cf3)

![Image](https://github.com/user-attachments/assets/20e61f17-9ff0-4c1c-8daf-6283e0b7f1bb)

Labels: New Feature
Request: base class with HTML repr but without being an 'Estimator'

### Describe the workflow you want to enable

Creating third-party packages that offer objects that are meant to be passed to estimators, but which aren't estimators themselves.

### Describe your proposed solution

Would be nice if there could be some class similar to `BaseEstimator` that would offer pretty printing, HTML representations, and so on; but without needing to be an estimator (e.g. without having metadata routing and similar).

This could be used for example as a base class for objects that are meant to be passed as constructor arguments to actual estimators, and which are thus desirable to show with a pretty-printed form when visualizing estimators. For example, something like parameterizable probability distributions offered as objects in third-party packages that are meant to be passed to estimators from said third-party packages.

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

_No response_

### Additional context

_No response_

COMMENT:
Interesting. Let me check which piece is missing.

Labels: New Feature
Request: base class with HTML repr but without being an 'Estimator'

### Describe the workflow you want to enable

Creating third-party packages that offer objects that are meant to be passed to estimators, but which aren't estimators themselves.

### Describe your proposed solution

Would be nice if there could be some class similar to `BaseEstimator` that would offer pretty printing, HTML representations, and so on; but without needing to be an estimator (e.g. without having metadata routing and similar).

This could be used for example as a base class for objects that are meant to be passed as constructor arguments to actual estimators, and which are thus desirable to show with a pretty-printed form when visualizing estimators. For example, something like parameterizable probability distributions offered as objects in third-party packages that are meant to be passed to estimators from said third-party packages.

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

_No response_

### Additional context

_No response_

COMMENT:
Oh yes, we expect a `_get_params_html` function (that calls `get_params`) and if it does not exist we only show a normal repr.

Somehow, we should try to isolate those into a mixin but I don't have it clear yet what should be the best way to do so (I foresee some potential recurrence issue). But having a single HTML mixin would be nice.

Labels: New Feature
Docs duplication between attributes and properties

### Describe the issue linked to the documentation

Docs for some classes mention some fitted-model attributes twice: first as 'attribute', then as 'property'.

For example, class SVC here:
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html

Shows `coef_` first under 'Attributes':
![Image](https://github.com/user-attachments/assets/3fbcad8a-69a1-49b2-928c-1ecdd495082d)

And then shows it again as a property:
![Image](https://github.com/user-attachments/assets/34b136e2-1afd-4768-891b-48c9ad433d92)

I am guessing this might be the autodoc plugin for sphinx being too eager with what it includes.

### Suggest a potential alternative/fix

Should show up only under 'attributes'.

COMMENT:
Indeed, by any means if you find a way to improve the situation, feel free to open a PR! Full disclosure: I don't think it is that easy, because `coef_` attribute is documented by hand and `coef_` property is automatically documented by sphinx ....

Labels: Documentation, help wanted
QDA is not reproducible

### Describe the bug

We are running QDA with default hyperparameters on the same dataset, on 2 different machines (linux). We find that the results change significantly when ran on a different machine. For more details, please see this Gist:
[https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d](https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d)

### Steps/Code to Reproduce

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Expected Results

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Actual Results

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Versions

```shell
Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d
```

COMMENT:
So quickly looking at it, it seems like this is Haswell vs SkyLakeX.

Just in case, could you try with the latest versions of all the packages to see if you still can reproduce the issue?

Labels: Bug, Needs Investigation
QDA is not reproducible

### Describe the bug

We are running QDA with default hyperparameters on the same dataset, on 2 different machines (linux). We find that the results change significantly when ran on a different machine. For more details, please see this Gist:
[https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d](https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d)

### Steps/Code to Reproduce

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Expected Results

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Actual Results

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Versions

```shell
Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d
```

COMMENT:
Which packages? Note that, I didn't see too many updates to QDA in scikit, so I have some doubts whether it was resolved (sorry I accidentally closed this but now is reopened).

Labels: Bug, Needs Investigation
QDA is not reproducible

### Describe the bug

We are running QDA with default hyperparameters on the same dataset, on 2 different machines (linux). We find that the results change significantly when ran on a different machine. For more details, please see this Gist:
[https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d](https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d)

### Steps/Code to Reproduce

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Expected Results

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Actual Results

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Versions

```shell
Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d
```

COMMENT:
> Which packages?

I believe sklearn and its dependencies: numpy, scipy.
The code looks quite simple and only uses numpy/scipy operations. So it's possible that the discrepency comes from a change in one of these libraries. It may also come from a change in the BLAS library they ship in which case we'll see it in the output of show_versions

Labels: Bug, Needs Investigation
QDA is not reproducible

### Describe the bug

We are running QDA with default hyperparameters on the same dataset, on 2 different machines (linux). We find that the results change significantly when ran on a different machine. For more details, please see this Gist:
[https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d](https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d)

### Steps/Code to Reproduce

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Expected Results

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Actual Results

Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d

### Versions

```shell
Please see the gist: https://gist.github.com/tomviering/43519a1f2a0e0ffe7569fb2a5ec2313d
```

COMMENT:
The `fit` method of `QuadraticDiscriminantAnalysis` uses `np.linalg.svd`, which, as I’ve found, does not guarantee reproducibility. See the related discussion here: https://github.com/numpy/numpy/issues/11500.

This might be the source of the issue.

Labels: Bug, Needs Investigation
Improve TargetEncoder predict time for single rows and many categories

As reported [here](https://tiago.rio.br/work/willbank/account/patching-scikit-learn-improve-api-performance/), `TargetEncoder.transform` is optimized for large `n_samples`. But in deployment mode, it might be single rows that matter. Combined with high cardinality of the categories, `transform` can be slow, but has room for improvement.

COMMENT:
Apparently, we were targeted by the same recommender system :)

I think that in general, our estimators are not the best when it comes to predict on a stream of data. The validation is usually an additional bottleneck. I'm wondering if we should try to address this issue. If so, I assume that there is a multiple way foreword.

Labels: Performance, module:preprocessing