Talip7/scikit-learn-issues-multilabel huggingface dataset:
Two possible logic errors potentially caused by typos

While reviewing the test suite, I found two redundant type checks that seem like logic errors caused by typos. Please check whether they are unintended mistakes.

1) In the function `check_as_frame(...)` of `/sklearn/datasets/tests/test_common.py`, the second assertion `assert isinstance(frame_X, pd.DataFrame)` should be `assert isinstance(frame_y, pd.DataFrame)` considering the code context.

```
    # Test for return_X_y and as_frame=True
    frame_X, frame_y = dataset_func(as_frame=True, return_X_y=True)
    assert isinstance(frame_X, pd.DataFrame)
    if frame_y.ndim > 1:
        assert isinstance(frame_X, pd.DataFrame)  # -> assert isinstance(frame_y, pd.DataFrame)
    else:
        assert isinstance(frame_y, pd.Series)
```

2) In the file `/sklearn/model_selection/tests/test_search.py`, the second assertion `assert hasattr(grid_search, "cv_results_")` should be `assert hasattr(random_search, "cv_results_")`.

```
def test_trivial_cv_results_attr():
    # Test search over a "grid" with only one point.
    clf = MockClassifier()
    grid_search = GridSearchCV(clf, {"foo_param": [1]}, cv=2)
    grid_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")

    random_search = RandomizedSearchCV(clf, {"foo_param": [0]}, n_iter=1, cv=2)
    random_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")  # -> assert hasattr(random_search, "cv_results_") 
```

COMMENT:
Hi, thanks for sharing the details of this issue. From what I understand, there are two small logic mistakes in the test files caused by copy-paste typos:

1. In 'test_common.py', the second assertion inside the 'if frame_y.ndim > 1:' block is incorrectly checking 'frame_X' again instead of 'frame_y'.
2. In 'test_search.py', the second assertion is checking 'grid_search' for 'cv_results_' instead of 'random_search'.

Both appear to be simple fixes in the test suite.

My plan is:

1. Update the incorrect assertions in both test files.
2. Run the relevant test modules locally to verify everything passes.
3. Submit a PR with the corrections and reference this issue.

If this approach looks good, could you please assign the issue to me? I’d be happy to work on it.

Thanks!

Labels: Needs Triage
Two possible logic errors potentially caused by typos

While reviewing the test suite, I found two redundant type checks that seem like logic errors caused by typos. Please check whether they are unintended mistakes.

1) In the function `check_as_frame(...)` of `/sklearn/datasets/tests/test_common.py`, the second assertion `assert isinstance(frame_X, pd.DataFrame)` should be `assert isinstance(frame_y, pd.DataFrame)` considering the code context.

```
    # Test for return_X_y and as_frame=True
    frame_X, frame_y = dataset_func(as_frame=True, return_X_y=True)
    assert isinstance(frame_X, pd.DataFrame)
    if frame_y.ndim > 1:
        assert isinstance(frame_X, pd.DataFrame)  # -> assert isinstance(frame_y, pd.DataFrame)
    else:
        assert isinstance(frame_y, pd.Series)
```

2) In the file `/sklearn/model_selection/tests/test_search.py`, the second assertion `assert hasattr(grid_search, "cv_results_")` should be `assert hasattr(random_search, "cv_results_")`.

```
def test_trivial_cv_results_attr():
    # Test search over a "grid" with only one point.
    clf = MockClassifier()
    grid_search = GridSearchCV(clf, {"foo_param": [1]}, cv=2)
    grid_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")

    random_search = RandomizedSearchCV(clf, {"foo_param": [0]}, n_iter=1, cv=2)
    random_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")  # -> assert hasattr(random_search, "cv_results_") 
```

COMMENT:
Hi, @manigkrish . This approach sounds good to me. Thank you for working on it!

Labels: Needs Triage
Two possible logic errors potentially caused by typos

While reviewing the test suite, I found two redundant type checks that seem like logic errors caused by typos. Please check whether they are unintended mistakes.

1) In the function `check_as_frame(...)` of `/sklearn/datasets/tests/test_common.py`, the second assertion `assert isinstance(frame_X, pd.DataFrame)` should be `assert isinstance(frame_y, pd.DataFrame)` considering the code context.

```
    # Test for return_X_y and as_frame=True
    frame_X, frame_y = dataset_func(as_frame=True, return_X_y=True)
    assert isinstance(frame_X, pd.DataFrame)
    if frame_y.ndim > 1:
        assert isinstance(frame_X, pd.DataFrame)  # -> assert isinstance(frame_y, pd.DataFrame)
    else:
        assert isinstance(frame_y, pd.Series)
```

2) In the file `/sklearn/model_selection/tests/test_search.py`, the second assertion `assert hasattr(grid_search, "cv_results_")` should be `assert hasattr(random_search, "cv_results_")`.

```
def test_trivial_cv_results_attr():
    # Test search over a "grid" with only one point.
    clf = MockClassifier()
    grid_search = GridSearchCV(clf, {"foo_param": [1]}, cv=2)
    grid_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")

    random_search = RandomizedSearchCV(clf, {"foo_param": [0]}, n_iter=1, cv=2)
    random_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")  # -> assert hasattr(random_search, "cv_results_") 
```

COMMENT:
Hi @rc4typecheck , I have pushed my changes and opened a PR referencing this issue. All relevant tests pass locally. Looking forward to your review!

Labels: Needs Triage
Two possible logic errors potentially caused by typos

While reviewing the test suite, I found two redundant type checks that seem like logic errors caused by typos. Please check whether they are unintended mistakes.

1) In the function `check_as_frame(...)` of `/sklearn/datasets/tests/test_common.py`, the second assertion `assert isinstance(frame_X, pd.DataFrame)` should be `assert isinstance(frame_y, pd.DataFrame)` considering the code context.

```
    # Test for return_X_y and as_frame=True
    frame_X, frame_y = dataset_func(as_frame=True, return_X_y=True)
    assert isinstance(frame_X, pd.DataFrame)
    if frame_y.ndim > 1:
        assert isinstance(frame_X, pd.DataFrame)  # -> assert isinstance(frame_y, pd.DataFrame)
    else:
        assert isinstance(frame_y, pd.Series)
```

2) In the file `/sklearn/model_selection/tests/test_search.py`, the second assertion `assert hasattr(grid_search, "cv_results_")` should be `assert hasattr(random_search, "cv_results_")`.

```
def test_trivial_cv_results_attr():
    # Test search over a "grid" with only one point.
    clf = MockClassifier()
    grid_search = GridSearchCV(clf, {"foo_param": [1]}, cv=2)
    grid_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")

    random_search = RandomizedSearchCV(clf, {"foo_param": [0]}, n_iter=1, cv=2)
    random_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")  # -> assert hasattr(random_search, "cv_results_") 
```

COMMENT:
@rc4typecheck can you explain how you found this, are you using some kind of automated tools as your GitHub handle would suggest? Can you elaborate a bit how your tool is working.

I would have appreciated that you explain this in the issue description 🙏!

Labels: Needs Triage
Two possible logic errors potentially caused by typos

While reviewing the test suite, I found two redundant type checks that seem like logic errors caused by typos. Please check whether they are unintended mistakes.

1) In the function `check_as_frame(...)` of `/sklearn/datasets/tests/test_common.py`, the second assertion `assert isinstance(frame_X, pd.DataFrame)` should be `assert isinstance(frame_y, pd.DataFrame)` considering the code context.

```
    # Test for return_X_y and as_frame=True
    frame_X, frame_y = dataset_func(as_frame=True, return_X_y=True)
    assert isinstance(frame_X, pd.DataFrame)
    if frame_y.ndim > 1:
        assert isinstance(frame_X, pd.DataFrame)  # -> assert isinstance(frame_y, pd.DataFrame)
    else:
        assert isinstance(frame_y, pd.Series)
```

2) In the file `/sklearn/model_selection/tests/test_search.py`, the second assertion `assert hasattr(grid_search, "cv_results_")` should be `assert hasattr(random_search, "cv_results_")`.

```
def test_trivial_cv_results_attr():
    # Test search over a "grid" with only one point.
    clf = MockClassifier()
    grid_search = GridSearchCV(clf, {"foo_param": [1]}, cv=2)
    grid_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")

    random_search = RandomizedSearchCV(clf, {"foo_param": [0]}, n_iter=1, cv=2)
    random_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")  # -> assert hasattr(random_search, "cv_results_") 
```

COMMENT:
This is an interesting one. I agree with @lesteve that we don't appreciate auto / AI generated issues w/o human oversight, especially since they usually don't bring much value.

In this particular sense, it seems like a valid report, but we'd appreciate transparency in the process on how the issue was found.

Labels: Needs Triage
Two possible logic errors potentially caused by typos

While reviewing the test suite, I found two redundant type checks that seem like logic errors caused by typos. Please check whether they are unintended mistakes.

1) In the function `check_as_frame(...)` of `/sklearn/datasets/tests/test_common.py`, the second assertion `assert isinstance(frame_X, pd.DataFrame)` should be `assert isinstance(frame_y, pd.DataFrame)` considering the code context.

```
    # Test for return_X_y and as_frame=True
    frame_X, frame_y = dataset_func(as_frame=True, return_X_y=True)
    assert isinstance(frame_X, pd.DataFrame)
    if frame_y.ndim > 1:
        assert isinstance(frame_X, pd.DataFrame)  # -> assert isinstance(frame_y, pd.DataFrame)
    else:
        assert isinstance(frame_y, pd.Series)
```

2) In the file `/sklearn/model_selection/tests/test_search.py`, the second assertion `assert hasattr(grid_search, "cv_results_")` should be `assert hasattr(random_search, "cv_results_")`.

```
def test_trivial_cv_results_attr():
    # Test search over a "grid" with only one point.
    clf = MockClassifier()
    grid_search = GridSearchCV(clf, {"foo_param": [1]}, cv=2)
    grid_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")

    random_search = RandomizedSearchCV(clf, {"foo_param": [0]}, n_iter=1, cv=2)
    random_search.fit(X, y)
    assert hasattr(grid_search, "cv_results_")  # -> assert hasattr(random_search, "cv_results_") 
```

COMMENT:
Fixed in https://github.com/scikit-learn/scikit-learn/pull/32735

Labels: Needs Triage
BUG: trees: `criterion="friedman_mse"` is buggy for multi-output

### Describe the bug

The calculation implemented in `FriedmanMSE.proxy_impurity_improvement` is plain wrong for the multi-output case.

When reading the code, it's fairly obvious that outputs are mixed in a way that doesn't mathematically make sense.

**Note:** I open this issue just for the records, as `"friedman_mse"` will be removed anyway (see #32700 )

### Steps/Code to Reproduce

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

X = [[1], [2], [3], [4]]
y = np.array([
    [1, -1],
    [1, -1],
    [0, 0],
    [0, 0]
])

tree = DecisionTreeRegressor(criterion="friedman_mse")
tree.fit(X, y)
plot_tree(tree);
```

### Expected Results

Split in the middle (x <= 2.5), reducing the error to 0 in one split.

### Actual Results

non-optimal split:

<img width="515" height="389" alt="Image" src="https://github.com/user-attachments/assets/7d42c1b5-0647-4b46-b5f5-9daa3b550247" />

### 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](https://file+.vscode-resource.vscode-cdn.net/home/arthur/dev-perso/scikit-learn/sklearn-env/bin/python)
   machine: Linux-6.14.0-35-generic-x86_64-with-glibc2.39

Python dependencies:
      sklearn: 1.8.dev0
          pip: None
   setuptools: 80.9.0
        numpy: 2.3.4
        scipy: 1.16.2
       Cython: 3.1.5
       pandas: 2.3.3
   matplotlib: 3.10.7
       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](https://file+.vscode-resource.vscode-cdn.net/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](https://file+.vscode-resource.vscode-cdn.net/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](https://file+.vscode-resource.vscode-cdn.net/usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
        version: None
```

COMMENT:
can i work on this issue ?

Labels: Bug
BUG: trees: `criterion="friedman_mse"` is buggy for multi-output

### Describe the bug

The calculation implemented in `FriedmanMSE.proxy_impurity_improvement` is plain wrong for the multi-output case.

When reading the code, it's fairly obvious that outputs are mixed in a way that doesn't mathematically make sense.

**Note:** I open this issue just for the records, as `"friedman_mse"` will be removed anyway (see #32700 )

### Steps/Code to Reproduce

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

X = [[1], [2], [3], [4]]
y = np.array([
    [1, -1],
    [1, -1],
    [0, 0],
    [0, 0]
])

tree = DecisionTreeRegressor(criterion="friedman_mse")
tree.fit(X, y)
plot_tree(tree);
```

### Expected Results

Split in the middle (x <= 2.5), reducing the error to 0 in one split.

### Actual Results

non-optimal split:

<img width="515" height="389" alt="Image" src="https://github.com/user-attachments/assets/7d42c1b5-0647-4b46-b5f5-9daa3b550247" />

### 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](https://file+.vscode-resource.vscode-cdn.net/home/arthur/dev-perso/scikit-learn/sklearn-env/bin/python)
   machine: Linux-6.14.0-35-generic-x86_64-with-glibc2.39

Python dependencies:
      sklearn: 1.8.dev0
          pip: None
   setuptools: 80.9.0
        numpy: 2.3.4
        scipy: 1.16.2
       Cython: 3.1.5
       pandas: 2.3.3
   matplotlib: 3.10.7
       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](https://file+.vscode-resource.vscode-cdn.net/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](https://file+.vscode-resource.vscode-cdn.net/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](https://file+.vscode-resource.vscode-cdn.net/usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
        version: None
```

COMMENT:
no, it's going to be fixed by PR #32708

Labels: Bug
BUG: trees: `criterion="friedman_mse"` is buggy for multi-output

### Describe the bug

The calculation implemented in `FriedmanMSE.proxy_impurity_improvement` is plain wrong for the multi-output case.

When reading the code, it's fairly obvious that outputs are mixed in a way that doesn't mathematically make sense.

**Note:** I open this issue just for the records, as `"friedman_mse"` will be removed anyway (see #32700 )

### Steps/Code to Reproduce

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

X = [[1], [2], [3], [4]]
y = np.array([
    [1, -1],
    [1, -1],
    [0, 0],
    [0, 0]
])

tree = DecisionTreeRegressor(criterion="friedman_mse")
tree.fit(X, y)
plot_tree(tree);
```

### Expected Results

Split in the middle (x <= 2.5), reducing the error to 0 in one split.

### Actual Results

non-optimal split:

<img width="515" height="389" alt="Image" src="https://github.com/user-attachments/assets/7d42c1b5-0647-4b46-b5f5-9daa3b550247" />

### 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](https://file+.vscode-resource.vscode-cdn.net/home/arthur/dev-perso/scikit-learn/sklearn-env/bin/python)
   machine: Linux-6.14.0-35-generic-x86_64-with-glibc2.39

Python dependencies:
      sklearn: 1.8.dev0
          pip: None
   setuptools: 80.9.0
        numpy: 2.3.4
        scipy: 1.16.2
       Cython: 3.1.5
       pandas: 2.3.3
   matplotlib: 3.10.7
       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](https://file+.vscode-resource.vscode-cdn.net/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](https://file+.vscode-resource.vscode-cdn.net/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](https://file+.vscode-resource.vscode-cdn.net/usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
        version: None
```

COMMENT:
At the moment Friedman MSE is only used for gradient boosting and our GB estimators fit one tree per output or class. Therefore, this bug should not be reachable by users at the moment.

That could change if we were to implement gradient boosting with vector leaves though.

Labels: Bug
BUG: trees: `criterion="friedman_mse"` is buggy for multi-output

### Describe the bug

The calculation implemented in `FriedmanMSE.proxy_impurity_improvement` is plain wrong for the multi-output case.

When reading the code, it's fairly obvious that outputs are mixed in a way that doesn't mathematically make sense.

**Note:** I open this issue just for the records, as `"friedman_mse"` will be removed anyway (see #32700 )

### Steps/Code to Reproduce

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

X = [[1], [2], [3], [4]]
y = np.array([
    [1, -1],
    [1, -1],
    [0, 0],
    [0, 0]
])

tree = DecisionTreeRegressor(criterion="friedman_mse")
tree.fit(X, y)
plot_tree(tree);
```

### Expected Results

Split in the middle (x <= 2.5), reducing the error to 0 in one split.

### Actual Results

non-optimal split:

<img width="515" height="389" alt="Image" src="https://github.com/user-attachments/assets/7d42c1b5-0647-4b46-b5f5-9daa3b550247" />

### 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](https://file+.vscode-resource.vscode-cdn.net/home/arthur/dev-perso/scikit-learn/sklearn-env/bin/python)
   machine: Linux-6.14.0-35-generic-x86_64-with-glibc2.39

Python dependencies:
      sklearn: 1.8.dev0
          pip: None
   setuptools: 80.9.0
        numpy: 2.3.4
        scipy: 1.16.2
       Cython: 3.1.5
       pandas: 2.3.3
   matplotlib: 3.10.7
       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](https://file+.vscode-resource.vscode-cdn.net/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](https://file+.vscode-resource.vscode-cdn.net/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](https://file+.vscode-resource.vscode-cdn.net/usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
        version: None
```

COMMENT:
Note that we still need to converge on the discussion in #32700 before any attempt to fix this issue though.

Labels: Bug