Talip7/scikit-learn-issues-multilabel huggingface dataset:
Iris Dataset Wrong Values.

### Describe the bug

There are three incorrect values in the Iris dataset, as follows:

(Instances from: https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/datasets/data/iris.csv)

In Row 36, the 4th feature is recorded as 0.2 instead of 0.1.
In Row 39, the 2nd feature is noted as 3.6 instead of 3.1.
In Row 39, the 3rd feature is documented as 1.4 instead of 1.5.

From Original Iris Dataset the rows are 35

### Steps/Code to Reproduce

iris = datasets.load_iris()
X = iris.data
y = iris.target

### Expected Results

Row 36 (35 from Original Dataset):   4.9,     3.1,     1.5,      0.1,     Iris-setosa
Row 39 (38 from Original Dataset):   4.9,     3.1,     1.5,      0.1,     Iris-setosa


### Actual Results

Row 36 (35 from Original Dataset):   4.9,     3.1,     1.5,      0.2,     Iris-setosa
Row 39 (38 from Original Dataset):   4.9,     3.6,     1.4,      0.1,     Iris-setosa

### Versions

```shell
System:
    python: 3.10.9 | packaged by Anaconda, Inc. | (main, Mar  1 2023, 18:18:15) [MSC v.1916 64 bit (AMD64)]
executable: C:\Users\stylelev\AppData\Local\anaconda3\python.exe
   machine: Windows-10-10.0.22621-SP0

Python dependencies:
      sklearn: 1.2.1
          pip: 22.3.1
   setuptools: 65.6.3
        numpy: 1.23.5
        scipy: 1.10.0
       Cython: None
       pandas: 1.5.3
   matplotlib: 3.7.0
       joblib: 1.1.1
threadpoolctl: 2.2.0

Built with OpenMP: True

threadpoolctl info:
       filepath: C:\Users\stylelev\AppData\Local\anaconda3\Library\bin\mkl_rt.1.dll
         prefix: mkl_rt
       user_api: blas
   internal_api: mkl
        version: 2021.4-Product
    num_threads: 4
threading_layer: intel

       filepath: C:\Users\stylelev\AppData\Local\anaconda3\vcomp140.dll
         prefix: vcomp
       user_api: openmp
   internal_api: openmp
        version: None
    num_threads: 4
```

COMMENT:
OK, so it seems that your source is the UCI dataset. We state that we are using the original version from the paper: https://onlinelibrary.wiley.com/doi/pdfdirect/10.1111/j.1469-1809.1936.tb02137.x

So we are fine here.

Labels: Bug, Needs Triage
Add clustering score?

### Describe the workflow you want to enable

I want to reproduce a paper that uses clustering score to measure the goodness of clustering.
I think they should be using adjusted rand index, but they use cluster accuracy.


### Describe your proposed solution

Something roughly like this:

```python
from sklearn.preprocessing import LabelEncoder

def cluster_accuracy(a, b):
    a, b = LabelEncoder().fit_transform(a), LabelEncoder().fit_transform(b)
    rows, cols = linear_sum_assignment(contingency_matrix(a, b), maximize=True)
    _, cols_inverse = np.unique(cols, return_index=True)
    return accuracy_score(a, cols_inverse[b])
```

### Describe alternatives you've considered, if relevant

I'm not sure if this is a good measure, but since it's used, maybe it's worth adding?
It's also not that hard to implement, but it took me 20 minutes to make sure I got it right (and I'm sure I missed some cases, for example when not all clusters appear?).

### Additional context
This is only relevant for evaluating the design of clustering algorithms since it's a supervised measure for clustering, and in clustering there's no lables. But that's true for most of the metrics we have implemented.

COMMENT:
In continuation of #27259 I guess

Labels: New Feature, Needs Triage
Add clustering score?

### Describe the workflow you want to enable

I want to reproduce a paper that uses clustering score to measure the goodness of clustering.
I think they should be using adjusted rand index, but they use cluster accuracy.


### Describe your proposed solution

Something roughly like this:

```python
from sklearn.preprocessing import LabelEncoder

def cluster_accuracy(a, b):
    a, b = LabelEncoder().fit_transform(a), LabelEncoder().fit_transform(b)
    rows, cols = linear_sum_assignment(contingency_matrix(a, b), maximize=True)
    _, cols_inverse = np.unique(cols, return_index=True)
    return accuracy_score(a, cols_inverse[b])
```

### Describe alternatives you've considered, if relevant

I'm not sure if this is a good measure, but since it's used, maybe it's worth adding?
It's also not that hard to implement, but it took me 20 minutes to make sure I got it right (and I'm sure I missed some cases, for example when not all clusters appear?).

### Additional context
This is only relevant for evaluating the design of clustering algorithms since it's a supervised measure for clustering, and in clustering there's no lables. But that's true for most of the metrics we have implemented.

COMMENT:
from sklearn.metrics import adjusted_rand_score

def calculate_ari(a, b):
return adjusted_rand_score(a, b)

or



from sklearn.metrics import adjusted_rand_score

true_labels = [0, 0, 1, 1, 2, 2]
predicted_clusters = [0, 0, 1, 1, 2, 3]

ari = adjusted_rand_score(true_labels, predicted_clusters)
print("Adjusted Rand Index:", ari)

Labels: New Feature, Needs Triage
Add clustering score?

### Describe the workflow you want to enable

I want to reproduce a paper that uses clustering score to measure the goodness of clustering.
I think they should be using adjusted rand index, but they use cluster accuracy.


### Describe your proposed solution

Something roughly like this:

```python
from sklearn.preprocessing import LabelEncoder

def cluster_accuracy(a, b):
    a, b = LabelEncoder().fit_transform(a), LabelEncoder().fit_transform(b)
    rows, cols = linear_sum_assignment(contingency_matrix(a, b), maximize=True)
    _, cols_inverse = np.unique(cols, return_index=True)
    return accuracy_score(a, cols_inverse[b])
```

### Describe alternatives you've considered, if relevant

I'm not sure if this is a good measure, but since it's used, maybe it's worth adding?
It's also not that hard to implement, but it took me 20 minutes to make sure I got it right (and I'm sure I missed some cases, for example when not all clusters appear?).

### Additional context
This is only relevant for evaluating the design of clustering algorithms since it's a supervised measure for clustering, and in clustering there's no lables. But that's true for most of the metrics we have implemented.

COMMENT:
I think adding more clustering metrics would make sense, but this one is kind of a duplicate / subset of https://github.com/scikit-learn/scikit-learn/issues/27259, so we better close this one and make decisions on the other issue.

Labels: New Feature, Needs Triage
scikit learn project runnable on pycharm but not on vscode?

### Describe the bug

Hello,

I recently created a python project using scikit learn on PyCharm. First, I followed the sample code on official website
`from sklearn import linear_model` and moved on to rest of the code.

Then I tried to run it on vscode, I set the interpreter to its venv, same as it was in pycharm, but i got the following error:

> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'

which is weird because i have never seen this erron on pycharm.

any idea what is going wrong?

### Steps/Code to Reproduce

just include `from sklearn import linear_model` in your code, assume you have installed the packages, both vscode and pycharm should compile and you wont see any error at this stage

### Expected Results

expected to run whatever the rest of your code is

### Actual Results

get an error 
> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'


### Versions

```shell
System:
    python: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
executable: .\venv\Scripts\python.exe
   machine: Windows-10-10.0.19045-SP0
Python dependencies:
      sklearn: 1.3.2
          pip: 23.3.1
   setuptools: 60.2.0
        numpy: 1.22.2
        scipy: 1.11.3
       Cython: None
       pandas: 1.4.1
   matplotlib: 3.5.1
       joblib: 1.3.2
threadpoolctl: 3.2.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: C:\Users\*\AppData\Local\Programs\Python\Python310\Lib\site-packages\numpy\.libs\libopenblas.EL2C6PLE4ZYW3ECEVIV3OXXGRN2NRFM2.gfortran-win_amd64.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen

       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: vcomp
       filepath: .\venv\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: .\venv\Lib\site-packages\scipy.libs\libopenblas_v0.3.20-571-g3dec11c6-gcc_10_3_0-c2315440d6b6cef5037bad648efc8c59.dll
        version: 0.3.21.dev
threading_layer: pthreads
   architecture: Zen
None
```

COMMENT:
This is probably a question about how to use pycharm and vs code and unlikely to be related to a bug in scikit-learn. We prefer to use the Issue tracker for discussions about work on scikit-learn and use the Discussions for support related topics. However I'd recommend you ask your question somewhere like a VS Code/PyCharm support group as it seems the problem is about how to make VS Code and PyCharm use the same venv on windows.

I'll close this issue for now, if after getting advice on PyCharm/VS Code it turns out this is a bug in scikit-learn, please do reopen it.

Labels: Bug, Needs Triage
scikit learn project runnable on pycharm but not on vscode?

### Describe the bug

Hello,

I recently created a python project using scikit learn on PyCharm. First, I followed the sample code on official website
`from sklearn import linear_model` and moved on to rest of the code.

Then I tried to run it on vscode, I set the interpreter to its venv, same as it was in pycharm, but i got the following error:

> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'

which is weird because i have never seen this erron on pycharm.

any idea what is going wrong?

### Steps/Code to Reproduce

just include `from sklearn import linear_model` in your code, assume you have installed the packages, both vscode and pycharm should compile and you wont see any error at this stage

### Expected Results

expected to run whatever the rest of your code is

### Actual Results

get an error 
> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'


### Versions

```shell
System:
    python: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
executable: .\venv\Scripts\python.exe
   machine: Windows-10-10.0.19045-SP0
Python dependencies:
      sklearn: 1.3.2
          pip: 23.3.1
   setuptools: 60.2.0
        numpy: 1.22.2
        scipy: 1.11.3
       Cython: None
       pandas: 1.4.1
   matplotlib: 3.5.1
       joblib: 1.3.2
threadpoolctl: 3.2.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: C:\Users\*\AppData\Local\Programs\Python\Python310\Lib\site-packages\numpy\.libs\libopenblas.EL2C6PLE4ZYW3ECEVIV3OXXGRN2NRFM2.gfortran-win_amd64.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen

       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: vcomp
       filepath: .\venv\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: .\venv\Lib\site-packages\scipy.libs\libopenblas_v0.3.20-571-g3dec11c6-gcc_10_3_0-c2315440d6b6cef5037bad648efc8c59.dll
        version: 0.3.21.dev
threading_layer: pthreads
   architecture: Zen
None
```

COMMENT:
@betatim I wonder if it is because of sklearn being deprecated. Like intuitively the solution to the error I mentioned should be something like `pip install sklearn`, but that would throw an error that suggests me to switch to scikit-learn instead. The official example still uses `import sklearn` in its sample code but while `scikit-learn` is encouraged instead? Correct me on this if I am wrong, but this does sound quite confusing to me...

Labels: Bug, Needs Triage
scikit learn project runnable on pycharm but not on vscode?

### Describe the bug

Hello,

I recently created a python project using scikit learn on PyCharm. First, I followed the sample code on official website
`from sklearn import linear_model` and moved on to rest of the code.

Then I tried to run it on vscode, I set the interpreter to its venv, same as it was in pycharm, but i got the following error:

> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'

which is weird because i have never seen this erron on pycharm.

any idea what is going wrong?

### Steps/Code to Reproduce

just include `from sklearn import linear_model` in your code, assume you have installed the packages, both vscode and pycharm should compile and you wont see any error at this stage

### Expected Results

expected to run whatever the rest of your code is

### Actual Results

get an error 
> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'


### Versions

```shell
System:
    python: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
executable: .\venv\Scripts\python.exe
   machine: Windows-10-10.0.19045-SP0
Python dependencies:
      sklearn: 1.3.2
          pip: 23.3.1
   setuptools: 60.2.0
        numpy: 1.22.2
        scipy: 1.11.3
       Cython: None
       pandas: 1.4.1
   matplotlib: 3.5.1
       joblib: 1.3.2
threadpoolctl: 3.2.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: C:\Users\*\AppData\Local\Programs\Python\Python310\Lib\site-packages\numpy\.libs\libopenblas.EL2C6PLE4ZYW3ECEVIV3OXXGRN2NRFM2.gfortran-win_amd64.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen

       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: vcomp
       filepath: .\venv\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: .\venv\Lib\site-packages\scipy.libs\libopenblas_v0.3.20-571-g3dec11c6-gcc_10_3_0-c2315440d6b6cef5037bad648efc8c59.dll
        version: 0.3.21.dev
threading_layer: pthreads
   architecture: Zen
None
```

COMMENT:
To understand the relation between sklearn, scikit-learn and `import sklearn` read the "Reason for the deprecation" section of https://pypi.org/project/sklearn/. The short answer is that the sklearn package on PyPI is there to redirect people who use it to the scikit-learn package (which is the only authoritative source, even though you `import sklearn`).

Labels: Bug, Needs Triage
scikit learn project runnable on pycharm but not on vscode?

### Describe the bug

Hello,

I recently created a python project using scikit learn on PyCharm. First, I followed the sample code on official website
`from sklearn import linear_model` and moved on to rest of the code.

Then I tried to run it on vscode, I set the interpreter to its venv, same as it was in pycharm, but i got the following error:

> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'

which is weird because i have never seen this erron on pycharm.

any idea what is going wrong?

### Steps/Code to Reproduce

just include `from sklearn import linear_model` in your code, assume you have installed the packages, both vscode and pycharm should compile and you wont see any error at this stage

### Expected Results

expected to run whatever the rest of your code is

### Actual Results

get an error 
> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'


### Versions

```shell
System:
    python: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
executable: .\venv\Scripts\python.exe
   machine: Windows-10-10.0.19045-SP0
Python dependencies:
      sklearn: 1.3.2
          pip: 23.3.1
   setuptools: 60.2.0
        numpy: 1.22.2
        scipy: 1.11.3
       Cython: None
       pandas: 1.4.1
   matplotlib: 3.5.1
       joblib: 1.3.2
threadpoolctl: 3.2.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: C:\Users\*\AppData\Local\Programs\Python\Python310\Lib\site-packages\numpy\.libs\libopenblas.EL2C6PLE4ZYW3ECEVIV3OXXGRN2NRFM2.gfortran-win_amd64.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen

       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: vcomp
       filepath: .\venv\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: .\venv\Lib\site-packages\scipy.libs\libopenblas_v0.3.20-571-g3dec11c6-gcc_10_3_0-c2315440d6b6cef5037bad648efc8c59.dll
        version: 0.3.21.dev
threading_layer: pthreads
   architecture: Zen
None
```

COMMENT:
@betatim yeah i read that explanation and that's where my confusion come from. does that mean if i have installed either scikit-learn or sklearn, `import sklearn` should compile and will import the intended package?

Labels: Bug, Needs Triage
scikit learn project runnable on pycharm but not on vscode?

### Describe the bug

Hello,

I recently created a python project using scikit learn on PyCharm. First, I followed the sample code on official website
`from sklearn import linear_model` and moved on to rest of the code.

Then I tried to run it on vscode, I set the interpreter to its venv, same as it was in pycharm, but i got the following error:

> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'

which is weird because i have never seen this erron on pycharm.

any idea what is going wrong?

### Steps/Code to Reproduce

just include `from sklearn import linear_model` in your code, assume you have installed the packages, both vscode and pycharm should compile and you wont see any error at this stage

### Expected Results

expected to run whatever the rest of your code is

### Actual Results

get an error 
> Traceback (most recent call last):
> from sklearn import linear_model
> ModuleNotFoundError: No module named 'sklearn'


### Versions

```shell
System:
    python: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
executable: .\venv\Scripts\python.exe
   machine: Windows-10-10.0.19045-SP0
Python dependencies:
      sklearn: 1.3.2
          pip: 23.3.1
   setuptools: 60.2.0
        numpy: 1.22.2
        scipy: 1.11.3
       Cython: None
       pandas: 1.4.1
   matplotlib: 3.5.1
       joblib: 1.3.2
threadpoolctl: 3.2.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: C:\Users\*\AppData\Local\Programs\Python\Python310\Lib\site-packages\numpy\.libs\libopenblas.EL2C6PLE4ZYW3ECEVIV3OXXGRN2NRFM2.gfortran-win_amd64.dll
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen

       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: vcomp
       filepath: .\venv\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: .\venv\Lib\site-packages\scipy.libs\libopenblas_v0.3.20-571-g3dec11c6-gcc_10_3_0-c2315440d6b6cef5037bad648efc8c59.dll
        version: 0.3.21.dev
threading_layer: pthreads
   architecture: Zen
None
```

COMMENT:
The recommendation is to install `scikit-learn` (not `sklearn`) and `import sklearn`.

Labels: Bug, Needs Triage
Typo at documentation of RandomForestRegressor

Hello,

is there a typo at the doc. description of the RandomForestRegressor? It states that the fitting of the data is done using "classifying decision trees" where it should be saying *regressor* decision trees.

see:
https://github.com/scikit-learn/scikit-learn/blob/e718c763fde3777aa05fe06c158ce4d6d1e85991/sklearn/ensemble/_forest.py#L1524-L1530

COMMENT:
Yes this is a bug. @colabfrr do you want to make a PR to correct this issue.

Labels: Bug, Documentation
MAINT Directly `cimport` interfaces from `std::algorithm`

Some Cython implementations use interfaces from the standard library of C++, namely `std::algorithm::move` and `std::algorithm::fill` from [`std::algorithm`](https://en.cppreference.com/w/cpp/algorithm/).

Before Cython 3, those interfaces had to be imported directly using the verbose syntax from Cython:
 - https://github.com/scikit-learn/scikit-learn/blob/5fc67aeb092d636895b599921283221a68c7a2ad/sklearn/metrics/_pairwise_distances_reduction/_radius_neighbors.pyx.tp#L22-L26
 - https://github.com/scikit-learn/scikit-learn/blob/5fc67aeb092d636895b599921283221a68c7a2ad/sklearn/metrics/_pairwise_distances_reduction/_middle_term_computer.pyx.tp#L28-L33

Cython 3 introduced the following line natively, for those interfaces. Those interfaces should now be `cimported` directly. That is one can replace the line shown above respectively with:

```cython
from libcpp.algorithm cimport move
from libcpp.algorithm cimport fill
```

I believe this is a good first Cython issue.

Any reader should feel free to pick it up. It might be possible that there is some context missing.

Please let me know if you need help. :slightly_smiling_face:

COMMENT:
I am working on this.

Labels: good first issue, cython
MAINT Directly `cimport` interfaces from `std::algorithm`

Some Cython implementations use interfaces from the standard library of C++, namely `std::algorithm::move` and `std::algorithm::fill` from [`std::algorithm`](https://en.cppreference.com/w/cpp/algorithm/).

Before Cython 3, those interfaces had to be imported directly using the verbose syntax from Cython:
 - https://github.com/scikit-learn/scikit-learn/blob/5fc67aeb092d636895b599921283221a68c7a2ad/sklearn/metrics/_pairwise_distances_reduction/_radius_neighbors.pyx.tp#L22-L26
 - https://github.com/scikit-learn/scikit-learn/blob/5fc67aeb092d636895b599921283221a68c7a2ad/sklearn/metrics/_pairwise_distances_reduction/_middle_term_computer.pyx.tp#L28-L33

Cython 3 introduced the following line natively, for those interfaces. Those interfaces should now be `cimported` directly. That is one can replace the line shown above respectively with:

```cython
from libcpp.algorithm cimport move
from libcpp.algorithm cimport fill
```

I believe this is a good first Cython issue.

Any reader should feel free to pick it up. It might be possible that there is some context missing.

Please let me know if you need help. :slightly_smiling_face:

COMMENT:
Our minimum supported Cython version is 0.29.33 currently: https://github.com/scikit-learn/scikit-learn/blob/a5fed0d77842a229a98655485530264c82ca59d6/sklearn/_min_dependencies.py#L20

Is there a way to use the new way for Cython >= 3 and the old way for Cython < 3?

I assume we want to keep supporting Cython < 3 for some time, in case some unintended Cython 3 bugs are discovered.

Labels: good first issue, cython