Talip7/scikit-learn-issues-multilabel huggingface dataset:
I want to import kerasregressor I have tried this from scikeras.wrappers import KerasClassifier , but I am getting the error  cannot import name '_deprecate_Xt_in_inverse_transform' from 'sklearn.utils.deprecation' (C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\deprecation.py)

### Describe the bug

I want to import kerasregressor I have tried this from scikeras.wrappers import KerasClassifier , but I am getting the error  cannot import name '_deprecate_Xt_in_inverse_transform' from 'sklearn.utils.deprecation' (C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\deprecation.py)

### Steps/Code to Reproduce

I want to import kerasregressor I have tried this from scikeras.wrappers import KerasClassifier , but I am getting the error  cannot import name '_deprecate_Xt_in_inverse_transform' from 'sklearn.utils.deprecation' (C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\deprecation.py)

### Expected Results

I want to import kerasregressor I have tried this from scikeras.wrappers import KerasClassifier , but I am getting the error  cannot import name '_deprecate_Xt_in_inverse_transform' from 'sklearn.utils.deprecation' (C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\deprecation.py)

### Actual Results

I want to import kerasregressor I have tried this from scikeras.wrappers import KerasClassifier , but I am getting the error  cannot import name '_deprecate_Xt_in_inverse_transform' from 'sklearn.utils.deprecation' (C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\deprecation.py)

### Versions

```shell
I want to import kerasregressor I have tried this from scikeras.wrappers import KerasClassifier , but I am getting the error  cannot import name '_deprecate_Xt_in_inverse_transform' from 'sklearn.utils.deprecation' (C:\Users\hp\AppData\Local\Programs\Python\Python311\Lib\site-packages\sklearn\utils\deprecation.py)
```

COMMENT:
You can try restarting the kernel.

Labels: Bug, Needs Triage
RFC Make creating a development environment easier

Our environment creating is becoming increasingly complicated. I re-thought of this in the context of https://github.com/scikit-learn/scikit-learn/pull/29012

xref: https://github.com/scikit-learn/scikit-learn/pull/29012#discussion_r1679046385

Quoting @lesteve :

---------------------------------------------------------------------
> Some possibilities off the top of my head:
> - have an environment.yml but then what do you do about pip users? scikit-image seems to have instructions that works for both, off the top of my head use `requirements.txt` and for conda: `conda create -n env python` + `conda install --file` that can use requirements.txt.
> - use an environment from the lock-files (`conda env create -f env.yml` or something like this), at least it is tested in the CI on some OS. This may be useful if we ever need to pin some stuff for some time. does not work for pip users.
> - have a spin custom command that installs the build dependencies and can switch between conda and pip. Maybe overkill
> 
> Side-comment: personally the one I am always annoyed until I switched to creating environment from lock-files directly is the doc dependencies so many different ones with a mix of conda and pip.
---------------------------------------------------------------------


I think @Micky774 had done some work in this regard, and back then I was against the idea. But our setup has become more and more complicated, and it might be time to introduce something for this?

COMMENT:
I can never find this command in our developer docs and even finding the "[building from source](https://scikit-learn.org/dev/developers/advanced_installation.html#building-from-source)" section is hard to find but isn't the command to install a dev env:
```
conda create -n sklearn-env -c conda-forge python numpy scipy cython meson-python ninja compilers
```
or a variation of this if you are using mamba or pip?

Though having written this, I realise you then would have to install `pytest` by hand. Are there other things missing (I think pre-commit installs things itself)?

Basically, can we undo (by putting in more effort) some of the accumulated complexity that has made it more complicated to setup a dev environment? I don't know the answer

Labels: Build / CI, RFC
RFC Make creating a development environment easier

Our environment creating is becoming increasingly complicated. I re-thought of this in the context of https://github.com/scikit-learn/scikit-learn/pull/29012

xref: https://github.com/scikit-learn/scikit-learn/pull/29012#discussion_r1679046385

Quoting @lesteve :

---------------------------------------------------------------------
> Some possibilities off the top of my head:
> - have an environment.yml but then what do you do about pip users? scikit-image seems to have instructions that works for both, off the top of my head use `requirements.txt` and for conda: `conda create -n env python` + `conda install --file` that can use requirements.txt.
> - use an environment from the lock-files (`conda env create -f env.yml` or something like this), at least it is tested in the CI on some OS. This may be useful if we ever need to pin some stuff for some time. does not work for pip users.
> - have a spin custom command that installs the build dependencies and can switch between conda and pip. Maybe overkill
> 
> Side-comment: personally the one I am always annoyed until I switched to creating environment from lock-files directly is the doc dependencies so many different ones with a mix of conda and pip.
---------------------------------------------------------------------


I think @Micky774 had done some work in this regard, and back then I was against the idea. But our setup has become more and more complicated, and it might be time to introduce something for this?

COMMENT:
For completeness the scikit-image install for [pip](https://scikit-image.org/docs/stable/user_guide/install.html#venv) and [conda](https://scikit-image.org/docs/stable/user_guide/install.html#id4).
- the good thing is that they reuse requirements.txt for both pip and conda files and have separate requirements.txt for doc, test, build, optional dependencies etc ... see https://github.com/scikit-image/scikit-image/tree/main/requirements
- the bad thing is that this is still quite a long list of commands to copy and paste

> Though having written this, I realise you then would have to install pytest by hand. Are there other things missing (I think pre-commit installs things itself)?

I think pretty that's pretty much it pytest and pre-commit (consensus is that it is kind of considered optional for new contributors because of its quirks).

The more problematic thing is if you want to build the doc (even without running the examples), the list of packages to install and the mix of conda and pip (some packages are not on conda-forge I guess).

Labels: Build / CI, RFC
RFC Make creating a development environment easier

Our environment creating is becoming increasingly complicated. I re-thought of this in the context of https://github.com/scikit-learn/scikit-learn/pull/29012

xref: https://github.com/scikit-learn/scikit-learn/pull/29012#discussion_r1679046385

Quoting @lesteve :

---------------------------------------------------------------------
> Some possibilities off the top of my head:
> - have an environment.yml but then what do you do about pip users? scikit-image seems to have instructions that works for both, off the top of my head use `requirements.txt` and for conda: `conda create -n env python` + `conda install --file` that can use requirements.txt.
> - use an environment from the lock-files (`conda env create -f env.yml` or something like this), at least it is tested in the CI on some OS. This may be useful if we ever need to pin some stuff for some time. does not work for pip users.
> - have a spin custom command that installs the build dependencies and can switch between conda and pip. Maybe overkill
> 
> Side-comment: personally the one I am always annoyed until I switched to creating environment from lock-files directly is the doc dependencies so many different ones with a mix of conda and pip.
---------------------------------------------------------------------


I think @Micky774 had done some work in this regard, and back then I was against the idea. But our setup has become more and more complicated, and it might be time to introduce something for this?

COMMENT:
Indeed. When I try to build the docs I end up in an even bigger search for the right commands/dependencies. Usually via first just trying to build the docs in the same environment I use for development and it not working.

Labels: Build / CI, RFC
RFC Make creating a development environment easier

Our environment creating is becoming increasingly complicated. I re-thought of this in the context of https://github.com/scikit-learn/scikit-learn/pull/29012

xref: https://github.com/scikit-learn/scikit-learn/pull/29012#discussion_r1679046385

Quoting @lesteve :

---------------------------------------------------------------------
> Some possibilities off the top of my head:
> - have an environment.yml but then what do you do about pip users? scikit-image seems to have instructions that works for both, off the top of my head use `requirements.txt` and for conda: `conda create -n env python` + `conda install --file` that can use requirements.txt.
> - use an environment from the lock-files (`conda env create -f env.yml` or something like this), at least it is tested in the CI on some OS. This may be useful if we ever need to pin some stuff for some time. does not work for pip users.
> - have a spin custom command that installs the build dependencies and can switch between conda and pip. Maybe overkill
> 
> Side-comment: personally the one I am always annoyed until I switched to creating environment from lock-files directly is the doc dependencies so many different ones with a mix of conda and pip.
---------------------------------------------------------------------


I think @Micky774 had done some work in this regard, and back then I was against the idea. But our setup has become more and more complicated, and it might be time to introduce something for this?

COMMENT:
About the doc environment, which seems the biggest pain point, we could start with a small PR to recommend conda users to do:
```
conda env create -f build_tools/circle/doc_environment.yml -n scikit-learn-doc
```

For pip users, then we keep the same thing for now and list all the packages you have to `pip install`.

Questions:
- not sure if we should use the same environment name as in the other instructions or a separate one (I used `scikit-learn-doc` here and I guess in other places `scikit-learn-dev`), maybe the same one, not sure about possible edge cases.

Advantages:
- this will create a conda env that is close enough to the CI environment and as such unexpected breakages are less likely
- recommending to use `conda env create` is simpler to explain to install conda-lock and create an environment from the lock-file
 
Downsides:
- only works for conda users

Full disclosure: personally since I am on Linux, I create the doc environment from the lock-file `build_tools/circle/doc_linux-64_conda.lock`.

Labels: Build / CI, RFC
GroupKFold inconsistent under ties in group sizes.

### Describe the bug

Due to the use of argsort (a non stable sort withthout the stable parameter introduced in numpy 2.0), GroupKFold is not always reproducible when there are ties in group sizes.

### Steps/Code to Reproduce

You may need to run this on different machines, but you can reproduce this issue with even less code than GroupKFold by simply testing `np.argsort`.
```
import numpy as np

x = np.array([0.37454012, 0.95071431, 0.73199394, 0.        , 0.15601864,
       0.        , 0.05808361, 0.86617615, 0.60111501, 0.70807258,
       0.02058449, 0.96990985, 0.83244264, 0.21233911, 0.18182497,
       0.18340451, 0.30424224, 0.52475643, 0.43194502, 0.29122914,
       0.61185289, 0.13949386, 0.29214465, 0.36636184, 0.45606998,
       0.78517596, 0.19967378, 0.51423444, 0.59241457, 0.        ,
       0.60754485, 0.17052412, 0.06505159, 0.        , 0.96563203,
       0.80839735, 0.        , 0.        , 0.68423303, 0.44015249,
       0.12203823])

print(np.argsort(x))
```
Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Expected Results

Technically a stable sort isn't required, no need to maintain the original ordering. However a consistent sort result is required for reproducibility.  Stable sort is an easy way to achieve this that is already built into numpy.

### Actual Results

Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Versions

```shell
sklearn versions are mostly irrelevant here as the issue is with calling a numpy method that requires additional changes.
```

COMMENT:
Are you able to reproduce this issue with GroupKFold? Perhaps I'm missing something

I have the following code, which seems to work:

```
def test_group_kfold_reproducible():
    # Check that iterating twice on the GroupKFold gives the same
    # sequence of train-test when the random_state is given
    # make many groups of same size
    for idx in range(100):
        groups = np.repeat(np.arange(50), 20)

        X = np.random.rand(1000)
        gkf = GroupKFold()

        first_split = [a for a in gkf.split(X, groups=groups)]
        second_split = [a for a in gkf.split(X, groups=groups)]
        for (train1, test1), (train2, test2) in zip(first_split, second_split):
            assert_array_equal(train1, train2)
            assert_array_equal(test1, test2)
```

Labels: Bug
GroupKFold inconsistent under ties in group sizes.

### Describe the bug

Due to the use of argsort (a non stable sort withthout the stable parameter introduced in numpy 2.0), GroupKFold is not always reproducible when there are ties in group sizes.

### Steps/Code to Reproduce

You may need to run this on different machines, but you can reproduce this issue with even less code than GroupKFold by simply testing `np.argsort`.
```
import numpy as np

x = np.array([0.37454012, 0.95071431, 0.73199394, 0.        , 0.15601864,
       0.        , 0.05808361, 0.86617615, 0.60111501, 0.70807258,
       0.02058449, 0.96990985, 0.83244264, 0.21233911, 0.18182497,
       0.18340451, 0.30424224, 0.52475643, 0.43194502, 0.29122914,
       0.61185289, 0.13949386, 0.29214465, 0.36636184, 0.45606998,
       0.78517596, 0.19967378, 0.51423444, 0.59241457, 0.        ,
       0.60754485, 0.17052412, 0.06505159, 0.        , 0.96563203,
       0.80839735, 0.        , 0.        , 0.68423303, 0.44015249,
       0.12203823])

print(np.argsort(x))
```
Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Expected Results

Technically a stable sort isn't required, no need to maintain the original ordering. However a consistent sort result is required for reproducibility.  Stable sort is an easy way to achieve this that is already built into numpy.

### Actual Results

Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Versions

```shell
sklearn versions are mostly irrelevant here as the issue is with calling a numpy method that requires additional changes.
```

COMMENT:
I meant, are you able to help us produce a code snippet that can produce an error on `main` branch using the `GroupKFold`? 

I presume we want a test case for this sort of thing (tho it sounds like it is hard to reproduce). Right @adrinjalali?

Labels: Bug
GroupKFold inconsistent under ties in group sizes.

### Describe the bug

Due to the use of argsort (a non stable sort withthout the stable parameter introduced in numpy 2.0), GroupKFold is not always reproducible when there are ties in group sizes.

### Steps/Code to Reproduce

You may need to run this on different machines, but you can reproduce this issue with even less code than GroupKFold by simply testing `np.argsort`.
```
import numpy as np

x = np.array([0.37454012, 0.95071431, 0.73199394, 0.        , 0.15601864,
       0.        , 0.05808361, 0.86617615, 0.60111501, 0.70807258,
       0.02058449, 0.96990985, 0.83244264, 0.21233911, 0.18182497,
       0.18340451, 0.30424224, 0.52475643, 0.43194502, 0.29122914,
       0.61185289, 0.13949386, 0.29214465, 0.36636184, 0.45606998,
       0.78517596, 0.19967378, 0.51423444, 0.59241457, 0.        ,
       0.60754485, 0.17052412, 0.06505159, 0.        , 0.96563203,
       0.80839735, 0.        , 0.        , 0.68423303, 0.44015249,
       0.12203823])

print(np.argsort(x))
```
Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Expected Results

Technically a stable sort isn't required, no need to maintain the original ordering. However a consistent sort result is required for reproducibility.  Stable sort is an easy way to achieve this that is already built into numpy.

### Actual Results

Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Versions

```shell
sklearn versions are mostly irrelevant here as the issue is with calling a numpy method that requires additional changes.
```

COMMENT:
xref re performance: https://github.com/scikit-learn/scikit-learn/issues/29531#issuecomment-2242827339

Labels: Bug
GroupKFold inconsistent under ties in group sizes.

### Describe the bug

Due to the use of argsort (a non stable sort withthout the stable parameter introduced in numpy 2.0), GroupKFold is not always reproducible when there are ties in group sizes.

### Steps/Code to Reproduce

You may need to run this on different machines, but you can reproduce this issue with even less code than GroupKFold by simply testing `np.argsort`.
```
import numpy as np

x = np.array([0.37454012, 0.95071431, 0.73199394, 0.        , 0.15601864,
       0.        , 0.05808361, 0.86617615, 0.60111501, 0.70807258,
       0.02058449, 0.96990985, 0.83244264, 0.21233911, 0.18182497,
       0.18340451, 0.30424224, 0.52475643, 0.43194502, 0.29122914,
       0.61185289, 0.13949386, 0.29214465, 0.36636184, 0.45606998,
       0.78517596, 0.19967378, 0.51423444, 0.59241457, 0.        ,
       0.60754485, 0.17052412, 0.06505159, 0.        , 0.96563203,
       0.80839735, 0.        , 0.        , 0.68423303, 0.44015249,
       0.12203823])

print(np.argsort(x))
```
Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Expected Results

Technically a stable sort isn't required, no need to maintain the original ordering. However a consistent sort result is required for reproducibility.  Stable sort is an easy way to achieve this that is already built into numpy.

### Actual Results

Both times with numpy version: 1.26.4
machine a: `array(3,5,29,33,36,37,10,6,32,40...`
machine b: `array(37,36,3,29,5,33,10,6,32,40...`

### Versions

```shell
sklearn versions are mostly irrelevant here as the issue is with calling a numpy method that requires additional changes.
```

COMMENT:
Checking back in on this issue. In response to the performance comment I ran a quick test https://github.com/scikit-learn/scikit-learn/issues/29531#issuecomment-2248678918, to show an example of the performance hit or speed up with a couple of different scenarios. Should this issue and attached PR wait for discussion there, or treated separately?

Additionally, what is scikit-learn's philosophy around fixing this sort of issue with an extra argument for GroupKFold, like `stable=False` to allow users to enforce stability if they are willing to take the performance change? If this would be a preferred option in this case, I can definitely implement that and any associated docs or unit tests.

Labels: Bug
Intersphinx duplicate definition warning

### Describe the bug

When using intersphinx with the scikit-learn docs, the build warns about duplicate definitions:

```
loading intersphinx inventory 'sklearn' from https://scikit-learn.org/stable/objects.inv...
WARNING: inventory <https://scikit-learn.org/stable/> contains multiple definitions for std:term:y
```

### Steps/Code to Reproduce

```python
intersphinx_mapping = {
    "sklearn": ("https://scikit-learn.org/stable/", None),
}
```

### Expected Results

No warning

### Actual Results

Warning about duplicate object definition

### Versions

```shell
Latest deployed documentation
```

COMMENT:
This looks like a duplicate of https://github.com/scikit-learn/scikit-learn/issues/29337. Let's re-open that issue if there is something new to discuss

Labels: Bug, Needs Triage
Intersphinx duplicate definition warning

### Describe the bug

When using intersphinx with the scikit-learn docs, the build warns about duplicate definitions:

```
loading intersphinx inventory 'sklearn' from https://scikit-learn.org/stable/objects.inv...
WARNING: inventory <https://scikit-learn.org/stable/> contains multiple definitions for std:term:y
```

### Steps/Code to Reproduce

```python
intersphinx_mapping = {
    "sklearn": ("https://scikit-learn.org/stable/", None),
}
```

### Expected Results

No warning

### Actual Results

Warning about duplicate object definition

### Versions

```shell
Latest deployed documentation
```

COMMENT:
I am getting this in a fresh CI run today, #29337 claims it was "magically fixed".

What can I do?

See https://github.com/cta-observatory/ctapipe/actions/runs/9938679990/job/27451630722?pr=2204#step:6:45

Labels: Bug, Needs Triage
Intersphinx duplicate definition warning

### Describe the bug

When using intersphinx with the scikit-learn docs, the build warns about duplicate definitions:

```
loading intersphinx inventory 'sklearn' from https://scikit-learn.org/stable/objects.inv...
WARNING: inventory <https://scikit-learn.org/stable/> contains multiple definitions for std:term:y
```

### Steps/Code to Reproduce

```python
intersphinx_mapping = {
    "sklearn": ("https://scikit-learn.org/stable/", None),
}
```

### Expected Results

No warning

### Actual Results

Warning about duplicate object definition

### Versions

```shell
Latest deployed documentation
```

COMMENT:
I'd copy your last comment from here to the old issue. I re-opened it.

Labels: Bug, Needs Triage