Talip7/scikit-learn-issues-multilabel huggingface dataset:
Leiden Clustering

### Describe the workflow you want to enable

The "Leiden" Clustering algorithm is considered one of the most powerful clustering algorithms, often outperforming competitors by a wide margin. 
The algorithm fulfils the inclusion criteria: its now 6 years old, has some 5200 citations. 

Currently, it is implemented in scanpy and cugraph where the latter includes a fast, gpu-enabled implementation. Due to its empirical performance, inclusion in scikit-learn would be a welcome addition for practitioners as it is vastly superior to most clustering algorithms currently included in scikit learn (on non-trivial datasets).

### Describe your proposed solution

I propose to include the Leiden algorithm as a clustering algorithm in scikit-learn.

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

_No response_

### Additional context

[From Louvain to Leiden: guaranteeing well-connected communities](https://www.nature.com/articles/s41598-019-41695-z)

COMMENT:
Thanks for the work you've done so far. In particular the level of detail and patience. 

The goal of this comment is to set expectations (and test drive this comment to see if we want to make it a standard comment).

Deciding on new features or substantial changes is a lengthy process. It frequently happens that no maintainer is available to take on this task right now. Unfortunately there is not a lot you can do about this - helping out on other issues or reviewing PRs were you have expertise are of course welcome but even that is only a "drop in the ocean" and doesn't directly increase the chances of a consensus being reached on this particular topic.

Please do not create a Pull Request before a decision has been made regarding the proposed work. Making this decision can
often take a significant amount of time and effort.

Labels: New Feature, Needs Decision - Include Feature
rendering of 'routing' note in the documentation

### Describe the issue linked to the documentation

the rendering of this section seems to be over-indented leading to some funky rendering in html:

example:

https://scikit-learn.org/stable/modules/generated/sklearn.cross_decomposition.CCA.html#sklearn.cross_decomposition.CCA.set_transform_request

<img width="1174" height="683" alt="Image" src="https://github.com/user-attachments/assets/740398db-819e-4df4-aa67-b274aa75412f" />

source code:

https://github.com/scikit-learn/scikit-learn/blob/2e4e40babb3ab86d2ed2185bc0dba7fdba9414f1/sklearn/utils/_metadata_requests.py#L1215

### Suggest a potential alternative/fix

remove one level of indent source code:

https://github.com/scikit-learn/scikit-learn/blob/2e4e40babb3ab86d2ed2185bc0dba7fdba9414f1/sklearn/utils/_metadata_requests.py#L1215

COMMENT:
it is very possible that this is intentional in case unindenting this leads to some doc build failure somewhere else: ignore this issue if that is the case

Labels: Documentation, Needs Triage
rendering of 'routing' note in the documentation

### Describe the issue linked to the documentation

the rendering of this section seems to be over-indented leading to some funky rendering in html:

example:

https://scikit-learn.org/stable/modules/generated/sklearn.cross_decomposition.CCA.html#sklearn.cross_decomposition.CCA.set_transform_request

<img width="1174" height="683" alt="Image" src="https://github.com/user-attachments/assets/740398db-819e-4df4-aa67-b274aa75412f" />

source code:

https://github.com/scikit-learn/scikit-learn/blob/2e4e40babb3ab86d2ed2185bc0dba7fdba9414f1/sklearn/utils/_metadata_requests.py#L1215

### Suggest a potential alternative/fix

remove one level of indent source code:

https://github.com/scikit-learn/scikit-learn/blob/2e4e40babb3ab86d2ed2185bc0dba7fdba9414f1/sklearn/utils/_metadata_requests.py#L1215

COMMENT:
Hi @Remi-Gau, the 8 spaces indentation is intentional. It was actually fixed not long ago, see https://github.com/scikit-learn/scikit-learn/issues/31804. 4 spaces for being the docstring of the method plus 4 spaces for the indentation of the method itself. With that in mind I'm closing this issue.

Labels: Documentation, Needs Triage
make sphinx directive about version more sklearn specific

### Describe the issue linked to the documentation

This is minor issue mostly affecting the rendering of the documentation of downstream libraries.

For example in Nilearn we use the TransformerMixin in quite a few of our estimators.

But when viewing the doc of our estimators, the sklearn methods of that mixin may have things like 'Added in version 1.3'

https://nilearn.github.io/stable/modules/generated/nilearn.maskers.SurfaceLabelsMasker.html#nilearn.maskers.SurfaceLabelsMasker.set_transform_request

<img width="1209" height="574" alt="Image" src="https://github.com/user-attachments/assets/38c33e22-6cef-4cc3-9656-3255cd9f029a" />

However Nilearn does not have a version 1.3 so this kind of look confusing.

### Suggest a potential alternative/fix

I am wondering if it would be possible to mention 'scikit-learn' in the sphinx directives that are about version (added, deprecated...)

COMMENT:
Note this is neither super important nor urgent.

But if this is something that would be possible I can take care of updating the directives.

Labels: Bug, Documentation
make sphinx directive about version more sklearn specific

### Describe the issue linked to the documentation

This is minor issue mostly affecting the rendering of the documentation of downstream libraries.

For example in Nilearn we use the TransformerMixin in quite a few of our estimators.

But when viewing the doc of our estimators, the sklearn methods of that mixin may have things like 'Added in version 1.3'

https://nilearn.github.io/stable/modules/generated/nilearn.maskers.SurfaceLabelsMasker.html#nilearn.maskers.SurfaceLabelsMasker.set_transform_request

<img width="1209" height="574" alt="Image" src="https://github.com/user-attachments/assets/38c33e22-6cef-4cc3-9656-3255cd9f029a" />

However Nilearn does not have a version 1.3 so this kind of look confusing.

### Suggest a potential alternative/fix

I am wondering if it would be possible to mention 'scikit-learn' in the sphinx directives that are about version (added, deprecated...)

COMMENT:
I agree that this is annoying. sphinx does not seems to be very specific about the format of the values used in this directive:

https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-versionadded

Maybe it's fine to replace `..versionchanged:: 1.7` by `..versionchanged:: scikit-learn 1.7` in docstrings of public base classes of scikit-learn that are meant to be derived in third-party libraries?

Maybe we should open a discussion on the sphinx repo itself, as this problem might have been resolved elsewhere already.

Labels: Bug, Documentation
make sphinx directive about version more sklearn specific

### Describe the issue linked to the documentation

This is minor issue mostly affecting the rendering of the documentation of downstream libraries.

For example in Nilearn we use the TransformerMixin in quite a few of our estimators.

But when viewing the doc of our estimators, the sklearn methods of that mixin may have things like 'Added in version 1.3'

https://nilearn.github.io/stable/modules/generated/nilearn.maskers.SurfaceLabelsMasker.html#nilearn.maskers.SurfaceLabelsMasker.set_transform_request

<img width="1209" height="574" alt="Image" src="https://github.com/user-attachments/assets/38c33e22-6cef-4cc3-9656-3255cd9f029a" />

However Nilearn does not have a version 1.3 so this kind of look confusing.

### Suggest a potential alternative/fix

I am wondering if it would be possible to mention 'scikit-learn' in the sphinx directives that are about version (added, deprecated...)

COMMENT:
> Maybe it's fine to replace `..versionchanged:: 1.7` by `..versionchanged:: scikit-learn 1.7` in docstrings of public base classes of scikit-learn that are meant to be derived in third-party libraries?

I was actually of doing something similar in our own library (`..versionchanged:: nilearn 0.12.0`) in case someone inherits from our own classes.

Labels: Bug, Documentation
make sphinx directive about version more sklearn specific

### Describe the issue linked to the documentation

This is minor issue mostly affecting the rendering of the documentation of downstream libraries.

For example in Nilearn we use the TransformerMixin in quite a few of our estimators.

But when viewing the doc of our estimators, the sklearn methods of that mixin may have things like 'Added in version 1.3'

https://nilearn.github.io/stable/modules/generated/nilearn.maskers.SurfaceLabelsMasker.html#nilearn.maskers.SurfaceLabelsMasker.set_transform_request

<img width="1209" height="574" alt="Image" src="https://github.com/user-attachments/assets/38c33e22-6cef-4cc3-9656-3255cd9f029a" />

However Nilearn does not have a version 1.3 so this kind of look confusing.

### Suggest a potential alternative/fix

I am wondering if it would be possible to mention 'scikit-learn' in the sphinx directives that are about version (added, deprecated...)

COMMENT:
In case this is useful to anyone, here's how we hacked things on our side downstream: add new directives the doc conf.py to call in our doc


```python

from sphinx.domains import changeset
from sphinx.locale import _

# adapting https://github.com/sphinx-doc/sphinx/blob/master/sphinx/domains/changeset.py
changeset.versionlabels["nilearn_versionadded"] = _("Added in Nilearn %s")
changeset.versionlabels["nilearn_versionchanged"] = _("Changed in Nilearn %s")
changeset.versionlabels["nilearn_deprecated"] = _(
    "Deprecated since Nilearn %s"
)
changeset.versionlabels["nilearn_versionremoved"] = _("Removed in Nilearn %s")
changeset.versionlabel_classes["nilearn_versionadded"] = "added"
changeset.versionlabel_classes["nilearn_versionchanged"] = "changed"
changeset.versionlabel_classes["nilearn_deprecated"] = "deprecated"
changeset.versionlabel_classes["nilearn_versionremoved"] = "removed"


def setup(app):
    app.add_directive("nilearn_versionadded", changeset.VersionChange)
    app.add_directive("nilearn_versionchanged", changeset.VersionChange)
    app.add_directive("nilearn_deprecated", changeset.VersionChange)
    app.add_directive("nilearn_versionremoved", changeset.VersionChange)

```

Then do some global search and replace `.. versionadded::` by `.. nilearn_versionadded::`

Note that you may also need to tweak your css if you want the html version to look similar to the classic sphinx directive.

Labels: Bug, Documentation
Setting weights on items when passing list of dicts to RandomizedSearchCV

### Describe the workflow you want to enable

We can pass a list of dictionaries to `RandomizedSearchCV`, for example

```python
[
    {"dim_reduction": "passthrough"},
    {
        "dim_reduction": PCA(),
        "dim_reduction__n_components": [10, 20, ...,]
    }
]
```

If I understand correctly [here](https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/model_selection/_search.py#L335) to get a set of hyperparameters one of the items in the list is chosen with equal probabilities, then a set of parameters is sampled from that dict.

In some cases it would be convenient to control the probability of choosing each list item. For example above I might want to invest more computation time in the "not passthrough" branch. Or if I have a column that can be either dropped or transformed I may want to explore more the "not drop" branch.

In other cases we have to create multiple list items due to nested estimators but that results in one choice for a hyperparameter to be over-represented. For example:

```python
[
    {
        "transformer": Flat(),
        "transformer__a": uniform(0.0, 1.0),
        "transformer__b": uniform(0.0, 1.0),
    },
    {
        "transformer": Nested(),
        "transformer__part": A(),
        "transformer__part__a": uniform(0.0, 1.0),
    },
    {
        "transformer": Nested(),
        "transformer__part": B(),
        "transformer__part__b": uniform(0.0, 1.0),
    },
]
```

I have to create 2 grid items for the Nested() option but if I am equally interested in the Flat() one I might want to set weights [1.0, 0.5, 0.5] on the list of param dicts. Maybe this is not a great example but what I mean is the amount of trials spent on one option can be driven by the structure of the estimators and how they are combined and sometimes it would be helpful to be able to correct or control it.


### Describe your proposed solution

Not sure what could be a nice API, maybe there would be a `distribution_weights` parameter which can only be used when `param_distributions` is a list (not dict) and which must be positive and have the same length as `param_distributions`

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

_No response_

### Additional context

this is more relevant for rather complex pipelines with many interdependant choices to make

COMMENT:
I find this proposal reasonable and reasonably straightforward to implement and document. However, this only works for the first level of discrete decisions. I took a look at how optuna deals with this, and it seems that they only allow for uniform discrete choice (`suggest_categorical`). However, since they can nest decision via the Python control flow, the second part of the problem stated in the description is not a problem.

Also, since optuna has adaptive optimization methods (TPE, Bayesion Optimization, ...), the initial marginal distribution over the choices is less of a problem because the model can learn a better sampling strategy for the next iterations which is not the case for randomized search.

Labels: New Feature, Needs Decision - Include Feature
⚠️ CI failed on Linux_Nightly.pylatest_pip_scipy_dev (last failure: Aug 28, 2025) ⚠️

**CI is still failing on [Linux_Nightly.pylatest_pip_scipy_dev](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=79396&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf)** (Aug 28, 2025)
Unable to find junit file. Please see link for details.

COMMENT:
Seems maybe like a Cython dev issue? From [build log](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=79365&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf):

Error when building:
```
error: redefinition of ‘__pyx_ff_map_fused_2_000_double__and_float’
```

More output:
```
 FAILED: [code=1] sklearn/_loss/_loss.cpython-313-x86_64-linux-gnu.so.p/meson-generated__loss.c.o
  ccache cc -Isklearn/_loss/_loss.cpython-313-x86_64-linux-gnu.so.p -Isklearn/_loss -I../../sklearn/_loss -I/home/vsts/miniforge3/envs/testvenv/include/python3.13 -fvisibility=hidden -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c11 -O3 -Wno-unused-but-set-variable -Wno-unused-function -Wno-conversion -Wno-misleading-indentation -fPIC -fopenmp -MD -MQ sklearn/_loss/_loss.cpython-313-x86_64-linux-gnu.so.p/meson-generated__loss.c.o -MF sklearn/_loss/_loss.cpython-313-x86_64-linux-gnu.so.p/meson-generated__loss.c.o.d -o sklearn/_loss/_loss.cpython-313-x86_64-linux-gnu.so.p/meson-generated__loss.c.o -c sklearn/_loss/_loss.cpython-313-x86_64-linux-gnu.so.p/_loss.c
  sklearn/_loss/_loss.cpython-313-x86_64-linux-gnu.so.p/_loss.c:6403:18: error: redefinition of ‘__pyx_ff_map_fused_2_000_double__and_float’
   6403 | static PyObject *__pyx_ff_map_fused_2_000_double__and_float(PyObject *__pyx_v_arg, PyTypeObject *__pyx_v_ndarray) {
        |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  sklearn/_loss/_loss.cpython-313-x86_64-linux-gnu.so.p/_loss.c:4994:18: note: previous definition of ‘__pyx_ff_map_fused_2_000_double__and_float’ with type ‘PyObject *(PyObject *, PyTypeObject *)’ {aka ‘struct _object *(struct _object *, struct _typeobject *)’}
   4994 | static PyObject *__pyx_ff_map_fused_2_000_double__and_float(PyObject *__pyx_v_arg, PyTypeObject *__pyx_v_ndarray) {
        |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Labels: Bug
⚠️ CI failed on Linux_Nightly.pylatest_pip_scipy_dev (last failure: Aug 28, 2025) ⚠️

**CI is still failing on [Linux_Nightly.pylatest_pip_scipy_dev](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=79396&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf)** (Aug 28, 2025)
Unable to find junit file. Please see link for details.

COMMENT:
Opened an issue in Cython about this: https://github.com/cython/cython/issues/7113

Labels: Bug
⚠️ CI failed on Linux_Nightly.pylatest_pip_scipy_dev (last failure: Aug 28, 2025) ⚠️

**CI is still failing on [Linux_Nightly.pylatest_pip_scipy_dev](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=79396&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf)** (Aug 28, 2025)
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=79431&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf) on Aug 29, 2025

Labels: Bug
⚠️ CI failed on Linux_Nightly.pylatest_pip_scipy_dev (last failure: Aug 28, 2025) ⚠️

**CI is still failing on [Linux_Nightly.pylatest_pip_scipy_dev](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=79396&view=logs&j=dfe99b15-50db-5d7b-b1e9-4105c42527cf)** (Aug 28, 2025)
Unable to find junit file. Please see link for details.

COMMENT:
The issue has been fixed by Cython and the last run was succesful, closing.

Labels: Bug
Implementing Divisive Analysis

### Describe the workflow you want to enable

I want to add Divisive Analysis Clustering to base scikit-learn in order to provide more options to developers.
"Divisive methods start when all objects are together (that is, at step 0 there is one cluster) and in each following step a cluster is split up, until there are _n_ of them." (Kaufman and Rousseeuw 1990). 

### Describe your proposed solution

Implement a class that performs divisive clustering extending BaseEstimatior and ClusterMixin.

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

_No response_

### Additional context

It has been implemented in R (cluster package). It's commonly used for marketing purposes and document and topic classification.

Kaufman, L., & Rousseeuw, P. J. (1990). Finding Groups in Data. En Wiley series in probability and statistics. https://doi.org/10.1002/9780470316801

COMMENT:
I propose implementing a new estimator class, e.g., DivisiveClustering, that:

Inherits from BaseEstimator and ClusterMixin
Supports standard scikit-learn API (fit, predict, etc.)
Accepts parameters for distance metrics, splitting criteria, and stopping rules
Returns cluster labels for each sample after fitting
Includes docstrings, examples, and unit tests
This implementation will be inspired by the R cluster package’s DIANA method, but follow scikit-learn’s API and coding standards.

Labels: New Feature, Hard, module:cluster, Needs Decision - Include Feature
Implementing Divisive Analysis

### Describe the workflow you want to enable

I want to add Divisive Analysis Clustering to base scikit-learn in order to provide more options to developers.
"Divisive methods start when all objects are together (that is, at step 0 there is one cluster) and in each following step a cluster is split up, until there are _n_ of them." (Kaufman and Rousseeuw 1990). 

### Describe your proposed solution

Implement a class that performs divisive clustering extending BaseEstimatior and ClusterMixin.

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

_No response_

### Additional context

It has been implemented in R (cluster package). It's commonly used for marketing purposes and document and topic classification.

Kaufman, L., & Rousseeuw, P. J. (1990). Finding Groups in Data. En Wiley series in probability and statistics. https://doi.org/10.1002/9780470316801

COMMENT:
@gthapa7 please wait for project maintainers to agree whether we want a new feature being including or not before discussing an implementation plan, in particular when the issue author themselves expressed in interest in contributing by themselves. Also, please do not post comments that mostly paraphrase what was said in the previous discussion or issue description. And please [do not use AI systems to write your comments](https://scikit-learn.org/dev/developers/contributing.html#automated-contributions-policy). Yours sounds suspiciously LLM generated.

Labels: New Feature, Hard, module:cluster, Needs Decision - Include Feature
Implementing Divisive Analysis

### Describe the workflow you want to enable

I want to add Divisive Analysis Clustering to base scikit-learn in order to provide more options to developers.
"Divisive methods start when all objects are together (that is, at step 0 there is one cluster) and in each following step a cluster is split up, until there are _n_ of them." (Kaufman and Rousseeuw 1990). 

### Describe your proposed solution

Implement a class that performs divisive clustering extending BaseEstimatior and ClusterMixin.

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

_No response_

### Additional context

It has been implemented in R (cluster package). It's commonly used for marketing purposes and document and topic classification.

Kaufman, L., & Rousseeuw, P. J. (1990). Finding Groups in Data. En Wiley series in probability and statistics. https://doi.org/10.1002/9780470316801

COMMENT:
@G4ll4rd0 we already implement [Bisecting KMeans](https://scikit-learn.org/stable/modules/clustering.html#bisecting-k-means) which is a form of divisive clustering. Do you have a particular need for another method? If so, which and why? Is there any evidence that what you ask cannot be achieved via the existing methods in scikit-learn?

Labels: New Feature, Hard, module:cluster, Needs Decision - Include Feature
Implementing Divisive Analysis

### Describe the workflow you want to enable

I want to add Divisive Analysis Clustering to base scikit-learn in order to provide more options to developers.
"Divisive methods start when all objects are together (that is, at step 0 there is one cluster) and in each following step a cluster is split up, until there are _n_ of them." (Kaufman and Rousseeuw 1990). 

### Describe your proposed solution

Implement a class that performs divisive clustering extending BaseEstimatior and ClusterMixin.

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

_No response_

### Additional context

It has been implemented in R (cluster package). It's commonly used for marketing purposes and document and topic classification.

Kaufman, L., & Rousseeuw, P. J. (1990). Finding Groups in Data. En Wiley series in probability and statistics. https://doi.org/10.1002/9780470316801

COMMENT:
@ogrisel I'd like to use other metrics for in-cluter distances and [Bisecting Kmeans](https://scikit-learn.org/stable/modules/clustering.html#bisecting-k-means) only uses L2 norm via [row_norms](https://github.com/scikit-learn/scikit-learn/blob/c5497b7f7/sklearn/cluster/_bisect_k_means.py#L83).

Labels: New Feature, Hard, module:cluster, Needs Decision - Include Feature
Create troubleshooting guide

## 🔧 Troubleshooting Guide

### Description
A troubleshooting guide would help users solve common problems.

### Suggested content:
- Common error messages and solutions
- Installation troubleshooting
- Configuration issues
- Performance problems

### Benefits:
- Reduces support burden
- Improves user experience
- Self-service help

### Type
- [ ] Documentation
- [ ] Enhancement
- [ ] Good first issue

---
*I'd like to help create a comprehensive troubleshooting guide!*

COMMENT:
See [#31970 (comment)](https://github.com/scikit-learn/scikit-learn/issues/31970#issuecomment-3204208173).

Labels: spam