Talip7/scikit-learn-issues-multilabel huggingface dataset:
Trees: impurity decrease calculation is buggy when there are missing values

### Describe the bug

In decision trees (both classif. and regression), the impurity decrease calculation is sometimes wrong when there are missing values in X.

This can lead to unexpectedly shallow trees when using `min_impurity_decrease` to control depth.

This was discovered during the investigations started by this issue: #32175

### Steps/Code to Reproduce

```Python
import numpy as np
from sklearn.tree import DecisionTreeRegressor

X = np.vstack([
    [0, 0, 0, 0, 1, 2, 3, 4],
    [1, 2, 1, 2, 1, 2, 1, 2]
]).swapaxes(0, 1).astype(float)
y = [0, 0, 0, 0, 1, 1, 1, 1]

n_leaves = []
for _ in range(1000):
    tree = DecisionTreeRegressor(max_depth=1, min_impurity_decrease=0.25).fit(X, y)
    # all the trees have two leaves
    assert tree.tree_.n_leaves == 2

X[X == 0] = np.nan
n_leaves_w_missing = []
for _ in range(1000):
    tree = DecisionTreeRegressor(max_depth=1, min_impurity_decrease=0.25).fit(X, y)
    n_leaves_w_missing.append(tree.tree_.n_leaves)

print(np.bincount(n_leaves_w_missing))
# prints [0 ~500 ~500]
```

The last print shows that in approx. half of the cases, the tree has only one leaf (i.e. no split).

### Expected Results

Chaning 0 by nan should have no impact on the tree construction in this example.

The tree should always have one split (and hence two leaves).

### Actual Results

In approx. half of the cases, the tree has only one leaf (i.e. no split).

### Versions

```shell
System:
    python: 3.12.11 (main, Aug 18 2025, 19:19:11) [Clang 20.1.4 ]
executable: /home/arthur/dev-perso/scikit-learn/sklearn-env/bin/python
   machine: Linux-6.14.0-29-generic-x86_64-with-glibc2.39

Python dependencies:
      sklearn: 1.8.dev0
          pip: None
   setuptools: 80.9.0
        numpy: 2.3.3
        scipy: 1.16.2
       Cython: 3.1.3
       pandas: None
   matplotlib: 3.10.6
       joblib: 1.5.2
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libscipy_openblas
       filepath: /home/arthur/dev-perso/scikit-learn/sklearn-env/lib/python3.12/site-packages/numpy.libs/libscipy_openblas64_-8fb3d286.so
        version: 0.3.30
threading_layer: pthreads
   architecture: Haswell

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libscipy_openblas
       filepath: /home/arthur/dev-perso/scikit-learn/sklearn-env/lib/python3.12/site-packages/scipy.libs/libscipy_openblas-b75cc656.so
        version: 0.3.29.dev
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: libgomp
       filepath: /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0
        version: None
```

COMMENT:
Closed by merged PR #32351

Labels: Bug, module:tree
⚠️ CI failed on Ubuntu_Atlas.ubuntu_atlas (last failure: Sep 13, 2025) ⚠️

**CI failed on [Ubuntu_Atlas.ubuntu_atlas](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=79967&view=logs&j=689a1c8f-ff4e-5689-1a1a-6fa551ae9eba)** (Sep 13, 2025)
- test_fit_transform[98]

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=80574&view=logs&j=689a1c8f-ff4e-5689-1a1a-6fa551ae9eba) on Oct 01, 2025

Labels: Bug, module:test-suite
⚠️ CI failed on Ubuntu_Atlas.ubuntu_atlas (last failure: Sep 13, 2025) ⚠️

**CI failed on [Ubuntu_Atlas.ubuntu_atlas](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=79967&view=logs&j=689a1c8f-ff4e-5689-1a1a-6fa551ae9eba)** (Sep 13, 2025)
- test_fit_transform[98]

COMMENT:
similar to https://github.com/scikit-learn/scikit-learn/issues/32184

Labels: Bug, module:test-suite
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
Discovered it while building the docs. I got an error the first time, the second time it just build but rendered incorrectly.

Error from first build:
```
/home/stefanie/code/scikit-learn_dev/scikit-learn/doc/modules/model_evaluation.rst:2188: ERROR: Undefined substitution referenced: "details-start".
/home/stefanie/code/scikit-learn_dev/scikit-learn/doc/modules/model_evaluation.rst:2188: ERROR: Undefined substitution referenced: "details-split".
/home/stefanie/code/scikit-learn_dev/scikit-learn/doc/modules/model_evaluation.rst:2230: ERROR: Undefined substitution referenced: "details-end".
```

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
I’d like to work on this if it’s ok!

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
Nice, @EmilyXinyi, go ahead. :)

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
You are right @StefanieSenger, `|details-start|`, `|details-split|`, `|details-end|` is the old notation.

Now we use the `.. dropdown` directive (see [guidelines for writing the user guide and other restructuredtext documents](https://scikit-learn.org/stable/developers/contributing.html#guidelines-for-writing-the-user-guide-and-other-restructuredtext-documents)).

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
Hi @StefanieSenger, @EmilyXinyi,

Can I also take this up? I’d like to help fix the rendering by replacing the old |details-start|/|details-split|/|details-end| with the .. dropdown:: directive, as suggested.

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
I’m a beginner and I’ve attempted to fix this issue. This PR includes the changes I made. I would greatly appreciate any feedback or suggestions for improvement. Thank you!

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
Looks like @VanshD-7657 put a PR out before I did and @lucyleeow has already started a review. 
@VanshD-7657 can take this over so no efforts go to waste, but for the future, it would be a good idea to wait for the author of the issue and/or the existing assignee to acknowledge the transfer before submitting a PR to avoid duplicate work. 

(I will review your PR though! And maybe @nithish-74 you can take a look at the PR reviews to learn as well)

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
Sorry @EmilyXinyi I should have policed that better, @VanshD-7657 please wait longer for a reply before taking over an issue

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
@EmilyXinyi please go ahead and submit your PR. @VanshD-7657 has violated guidelines multiple times and is banned from the org now.

Labels: Easy, Documentation
Fix rendering of D2 Brier score section in User Guide

_This is an issue for a contributor who has worked with rst and sphinx documentation before, or who wants to spend 10 hours to learn on the task. It is not suitable for ai agents._

The newly added section about **D2 Brier score** (added via #28971) doesn't render correctly in the User Guide.
In the 1.8 dev version documentation it renders as 

```
|details-start| D2 Brier score |details-split|
...
|details-end|
```

We probably need to use .`. dropdown::` like in the section above.

Maybe @elhambb, do you want to take care of it?
Also @star1327p or @EmilyXinyi, if that's not too boring for you.

COMMENT:
@EmilyXinyi Are you interested in working on this?

Labels: Easy, Documentation
⚠️ CI failed on Wheel builder (last failure: Sep 29, 2025) ⚠️

**CI is still failing on [Wheel builder](https://github.com/scikit-learn/scikit-learn/actions/runs/18085163372)** (Sep 29, 2025)

COMMENT:
All the macos x86 jobs are getting killed after running ~27% of the tests

Labels: Build / CI, Needs Investigation
⚠️ CI failed on Wheel builder (last failure: Sep 29, 2025) ⚠️

**CI is still failing on [Wheel builder](https://github.com/scikit-learn/scikit-learn/actions/runs/18085163372)** (Sep 29, 2025)

COMMENT:
Looking at the [last succesful log](https://github.com/scikit-learn/scikit-learn/actions/runs/17633425598/job/50105196464#step:5:1903) it has scipy 1.16.1 with OpenBLAS 0.3.28.

The [first failing log](https://github.com/scikit-learn/scikit-learn/actions/runs/17663927075/job/50202222298#step:5:1903) has scipy 1.16.2 and OpenBLAS 0.3.29.dev.

This may well be a red herring, hard to tell without debugging this further ...

Labels: Build / CI, Needs Investigation
⚠️ CI failed on Wheel builder (last failure: Sep 29, 2025) ⚠️

**CI is still failing on [Wheel builder](https://github.com/scikit-learn/scikit-learn/actions/runs/18085163372)** (Sep 29, 2025)

COMMENT:
Requiring `scipy<1.16.2` fixes the hang, I opened #32273 as a temporary work-around until we investigate more and report it upstream.

Labels: Build / CI, Needs Investigation
Unexpected behavior when combining FunctionTransformer and pandas DataFrames

### Describe the bug

When using a pandas `DataFrame` with the `FunctionTransformer(func=..., feature_names_out='one-to-one')` on data with the wrong column order, the column names are mixed. While this behavior might be derived from the documentation, it still felt unexpected.

### Steps/Code to Reproduce

```py
from sklearn.preprocessing import FunctionTransformer
import pandas as pd

newdf = pd.DataFrame({"a": [1,2], "b": [True, False], "c": ["x", "y"]})
newdf_shuffled_cols = newdf[["c", "a", "b"]]

def testfun(x):
    return x

# From the docs:
# If func returns an output with a columns attribute, then the columns is 
# enforced to be consistent with the output of get_feature_names_out.

functrans = FunctionTransformer(func=testfun, feature_names_out='one-to-one')
functrans.fit(newdf)
transformed = functrans.transform(newdf_shuffled_cols)
print(newdf["c"])
print(transformed["c"])
```

### Expected Results

The same column is returned.

### Actual Results

```
0    x
1    y
Name: c, dtype: object
0     True
1    False
Name: c, dtype: bool
```

### Versions

```shell
System:
    python: 3.13.7 | packaged by conda-forge | (main, Sep  3 2025, 14:30:35) [GCC 14.3.0]
executable: /opt/conda/envs/sklearn_burg/bin/python3
   machine: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.7.2
          pip: 25.2
   setuptools: 80.9.0
        numpy: 2.3.3
        scipy: 1.16.1
       Cython: None
       pandas: 2.3.2
   matplotlib: None
       joblib: 1.5.2
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 28
         prefix: libopenblas
       filepath: /opt/conda/envs/sklearn_burg/lib/libopenblasp-r0.3.30.so
        version: 0.3.30
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 28
         prefix: libgomp
       filepath: /opt/conda/envs/sklearn_burg/lib/libgomp.so.1.0.0
        version: None
```

COMMENT:
Funnily enough I debugged my entire `Pipeline` only to find this in the first step. #28780 is related.

Labels: Bug, Needs Decision
Unexpected behavior when combining FunctionTransformer and pandas DataFrames

### Describe the bug

When using a pandas `DataFrame` with the `FunctionTransformer(func=..., feature_names_out='one-to-one')` on data with the wrong column order, the column names are mixed. While this behavior might be derived from the documentation, it still felt unexpected.

### Steps/Code to Reproduce

```py
from sklearn.preprocessing import FunctionTransformer
import pandas as pd

newdf = pd.DataFrame({"a": [1,2], "b": [True, False], "c": ["x", "y"]})
newdf_shuffled_cols = newdf[["c", "a", "b"]]

def testfun(x):
    return x

# From the docs:
# If func returns an output with a columns attribute, then the columns is 
# enforced to be consistent with the output of get_feature_names_out.

functrans = FunctionTransformer(func=testfun, feature_names_out='one-to-one')
functrans.fit(newdf)
transformed = functrans.transform(newdf_shuffled_cols)
print(newdf["c"])
print(transformed["c"])
```

### Expected Results

The same column is returned.

### Actual Results

```
0    x
1    y
Name: c, dtype: object
0     True
1    False
Name: c, dtype: bool
```

### Versions

```shell
System:
    python: 3.13.7 | packaged by conda-forge | (main, Sep  3 2025, 14:30:35) [GCC 14.3.0]
executable: /opt/conda/envs/sklearn_burg/bin/python3
   machine: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.7.2
          pip: 25.2
   setuptools: 80.9.0
        numpy: 2.3.3
        scipy: 1.16.1
       Cython: None
       pandas: 2.3.2
   matplotlib: None
       joblib: 1.5.2
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 28
         prefix: libopenblas
       filepath: /opt/conda/envs/sklearn_burg/lib/libopenblasp-r0.3.30.so
        version: 0.3.30
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 28
         prefix: libgomp
       filepath: /opt/conda/envs/sklearn_burg/lib/libgomp.so.1.0.0
        version: None
```

COMMENT:
I solved this issue by passing all tests and also adding the snippet as a proof of solving issue. I am a beginner, Please let me know and guide me for further step.

Labels: Bug, Needs Decision
Unexpected behavior when combining FunctionTransformer and pandas DataFrames

### Describe the bug

When using a pandas `DataFrame` with the `FunctionTransformer(func=..., feature_names_out='one-to-one')` on data with the wrong column order, the column names are mixed. While this behavior might be derived from the documentation, it still felt unexpected.

### Steps/Code to Reproduce

```py
from sklearn.preprocessing import FunctionTransformer
import pandas as pd

newdf = pd.DataFrame({"a": [1,2], "b": [True, False], "c": ["x", "y"]})
newdf_shuffled_cols = newdf[["c", "a", "b"]]

def testfun(x):
    return x

# From the docs:
# If func returns an output with a columns attribute, then the columns is 
# enforced to be consistent with the output of get_feature_names_out.

functrans = FunctionTransformer(func=testfun, feature_names_out='one-to-one')
functrans.fit(newdf)
transformed = functrans.transform(newdf_shuffled_cols)
print(newdf["c"])
print(transformed["c"])
```

### Expected Results

The same column is returned.

### Actual Results

```
0    x
1    y
Name: c, dtype: object
0     True
1    False
Name: c, dtype: bool
```

### Versions

```shell
System:
    python: 3.13.7 | packaged by conda-forge | (main, Sep  3 2025, 14:30:35) [GCC 14.3.0]
executable: /opt/conda/envs/sklearn_burg/bin/python3
   machine: Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.7.2
          pip: 25.2
   setuptools: 80.9.0
        numpy: 2.3.3
        scipy: 1.16.1
       Cython: None
       pandas: 2.3.2
   matplotlib: None
       joblib: 1.5.2
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 28
         prefix: libopenblas
       filepath: /opt/conda/envs/sklearn_burg/lib/libopenblasp-r0.3.30.so
        version: 0.3.30
threading_layer: pthreads
   architecture: Haswell

       user_api: openmp
   internal_api: openmp
    num_threads: 28
         prefix: libgomp
       filepath: /opt/conda/envs/sklearn_burg/lib/libgomp.so.1.0.0
        version: None
```

COMMENT:
We need to wait and see what we conclude on https://github.com/scikit-learn/scikit-learn/issues/28780 which is quite related.

Labels: Bug, Needs Decision
Evaluate multi-threading `LogisticRegression`

When https://github.com/scikit-learn/scikit-learn/pull/32073 is merged, `n_jobs` will have no effect in `LogisticRegression` so should be deprecated.

It's also a good time to consider enabling multi-threading to compute the logistic regression path here https://github.com/scikit-learn/scikit-learn/blob/21e0df780772e9567b09249a05a42dfde6de465d/sklearn/linear_model/_logistic.py#L1373-L1388

So far it was disabled because parallelism was happening at a higher level using joblib. Now we should benchmark the impact of enabling multi-threading to see if it's positive for all the solvers and a wide range of problems.
Like for other estimators using OpenMP-based multi-threading, the number of thread should not be controlled by `n_jobs` but instead use all available core (`n_threads = _openmp_effective_n_threads()`).

COMMENT:
I’d like to take this up. Plan is to handle the `n_jobs `deprecation and then benchmark the impact of enabling multi-threading across different solvers and datasets. I’ll also look into using `_openmp_effective_n_threads()` consistently, as done in other estimators.

Labels: API, help wanted, Needs Benchmarks
Evaluate multi-threading `LogisticRegression`

When https://github.com/scikit-learn/scikit-learn/pull/32073 is merged, `n_jobs` will have no effect in `LogisticRegression` so should be deprecated.

It's also a good time to consider enabling multi-threading to compute the logistic regression path here https://github.com/scikit-learn/scikit-learn/blob/21e0df780772e9567b09249a05a42dfde6de465d/sklearn/linear_model/_logistic.py#L1373-L1388

So far it was disabled because parallelism was happening at a higher level using joblib. Now we should benchmark the impact of enabling multi-threading to see if it's positive for all the solvers and a wide range of problems.
Like for other estimators using OpenMP-based multi-threading, the number of thread should not be controlled by `n_jobs` but instead use all available core (`n_threads = _openmp_effective_n_threads()`).

COMMENT:
FYI I created #32739 to do the simple part of deprecating `n_jobs` in `LogisticRegression` for the 1.8 relase. We can keep this issue about evalutating multi-threading which is longer term.

Labels: API, help wanted, Needs Benchmarks