Talip7/scikit-learn-issues-multilabel huggingface dataset:
⚠️ CI failed on Linux_Nightly_PyPy.pypy3 ⚠️

**CI failed on [Linux_Nightly_PyPy.pypy3](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=48488&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66)** (Nov 08, 2022)
Unable to find junit file. Please see link for details.

COMMENT:
The job got killed. It is weird because it does not seem like a timeout but it is not a segmentation fault either.

Labels: Build / CI
⚠️ CI failed on Linux_Nightly_PyPy.pypy3 ⚠️

**CI failed on [Linux_Nightly_PyPy.pypy3](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=48488&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66)** (Nov 08, 2022)
Unable to find junit file. Please see link for details.

COMMENT:
## CI is no longer failing! ✅

[Successful run](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=48743&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66) on Nov 15, 2022

Labels: Build / CI
⚠️ CI failed on Linux_Nightly_PyPy.pypy3 ⚠️

**CI failed on [Linux_Nightly_PyPy.pypy3](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=48488&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66)** (Nov 08, 2022)
Unable to find junit file. Please see link for details.

COMMENT:
The error on the November 8th failure:
https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=48488&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66

```
/home/vsts/work/_temp/4b34890e-d165-4992-a3ae-65ea7751ec41.sh: line 1:  4176 Killed                  docker exec skcontainer ./build_tools/azure/test_script.sh
##[error]Bash exited with code '137'.
```

Not exactly the same but maybe a bit similar from the November 4th failure (https://github.com/scikit-learn/scikit-learn/issues/24831):
https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=48358&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66&t=0cdfadab-878f-502c-9df1-54a896e98c4f

```
##[error]Exit code 137 returned from process: file name '/home/vsts/agents/2.211.1/externals/node10/bin/node', arguments '"/home/vsts/work/_tasks/CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9/2.201.1/cmdline.js"'.
```

In both cases, it looks like the tests run gets close to 100% completion but gets killed for some reason ...

Maybe leave this one open for a few days to see how often this happens?

Labels: Build / CI
⚠️ CI failed on Linux_Nightly_PyPy.pypy3 ⚠️

**CI failed on [Linux_Nightly_PyPy.pypy3](https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=48488&view=logs&j=0b16f832-29d6-5b92-1c23-eb006f606a66)** (Nov 08, 2022)
Unable to find junit file. Please see link for details.

COMMENT:
The PyPy scheduled build has not failed since November 9th, I think we can close this for now.

Labels: Build / CI
Make it possible to specify interaction_cst and monotonic_cst with feature names.

### Describe the workflow you want to enable

Instead of passing an array of monotonicity constraints (`-1` for a decrease constraint, `+1` for an increase constraint or `0` for no constraint) specified by feature positions in the training set, it would be more convenient to pass a `dict` to pass constraints spec only for the required feature names (when those are available as `str` values in the dataset columns). For instance

```python
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor

X, y = load_diabetes(return_X_y=True, as_frame=True)

reg = HistGradientBoostingRegressor(
    monotonic_cst={"bmi": +1, "s3": -1}
)
reg.fit(X, y)
```

Not that here X has column names because it is a pandas dataframe.

See #24845 for a similar feature for `interaction_cst` by passing a list of tuple of `str` names instead.

### Describe your proposed solution

This requires updating the `fit` method, docstring and examples to accept a dict of constraints with feature names as keys.

If `feature_names_in_` is not defined in `fit`, then a value error with a helpful error message must be raised.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Once #13649 is finalized and merged, a similar treatment should be adapted to it for the sake of consistency.

COMMENT:
I will give it a quick shot.

Labels: Enhancement
Make it possible to specify interaction_cst and monotonic_cst with feature names.

### Describe the workflow you want to enable

Instead of passing an array of monotonicity constraints (`-1` for a decrease constraint, `+1` for an increase constraint or `0` for no constraint) specified by feature positions in the training set, it would be more convenient to pass a `dict` to pass constraints spec only for the required feature names (when those are available as `str` values in the dataset columns). For instance

```python
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor

X, y = load_diabetes(return_X_y=True, as_frame=True)

reg = HistGradientBoostingRegressor(
    monotonic_cst={"bmi": +1, "s3": -1}
)
reg.fit(X, y)
```

Not that here X has column names because it is a pandas dataframe.

See #24845 for a similar feature for `interaction_cst` by passing a list of tuple of `str` names instead.

### Describe your proposed solution

This requires updating the `fit` method, docstring and examples to accept a dict of constraints with feature names as keys.

If `feature_names_in_` is not defined in `fit`, then a value error with a helpful error message must be raised.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Once #13649 is finalized and merged, a similar treatment should be adapted to it for the sake of consistency.

COMMENT:
I am working on a similar UX improvement for `categorical_features`.

Labels: Enhancement
Make it possible to specify interaction_cst and monotonic_cst with feature names.

### Describe the workflow you want to enable

Instead of passing an array of monotonicity constraints (`-1` for a decrease constraint, `+1` for an increase constraint or `0` for no constraint) specified by feature positions in the training set, it would be more convenient to pass a `dict` to pass constraints spec only for the required feature names (when those are available as `str` values in the dataset columns). For instance

```python
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor

X, y = load_diabetes(return_X_y=True, as_frame=True)

reg = HistGradientBoostingRegressor(
    monotonic_cst={"bmi": +1, "s3": -1}
)
reg.fit(X, y)
```

Not that here X has column names because it is a pandas dataframe.

See #24845 for a similar feature for `interaction_cst` by passing a list of tuple of `str` names instead.

### Describe your proposed solution

This requires updating the `fit` method, docstring and examples to accept a dict of constraints with feature names as keys.

If `feature_names_in_` is not defined in `fit`, then a value error with a helpful error message must be raised.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Once #13649 is finalized and merged, a similar treatment should be adapted to it for the sake of consistency.

COMMENT:
> If feature_names_in_ is defined in fit, then a value error with a helpful error message must be raised.

Did you mean „if … is NOT defined, …“?

Labels: Enhancement
Make it possible to specify interaction_cst and monotonic_cst with feature names.

### Describe the workflow you want to enable

Instead of passing an array of monotonicity constraints (`-1` for a decrease constraint, `+1` for an increase constraint or `0` for no constraint) specified by feature positions in the training set, it would be more convenient to pass a `dict` to pass constraints spec only for the required feature names (when those are available as `str` values in the dataset columns). For instance

```python
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor

X, y = load_diabetes(return_X_y=True, as_frame=True)

reg = HistGradientBoostingRegressor(
    monotonic_cst={"bmi": +1, "s3": -1}
)
reg.fit(X, y)
```

Not that here X has column names because it is a pandas dataframe.

See #24845 for a similar feature for `interaction_cst` by passing a list of tuple of `str` names instead.

### Describe your proposed solution

This requires updating the `fit` method, docstring and examples to accept a dict of constraints with feature names as keys.

If `feature_names_in_` is not defined in `fit`, then a value error with a helpful error message must be raised.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Once #13649 is finalized and merged, a similar treatment should be adapted to it for the sake of consistency.

COMMENT:
`monotonic_cst` was implemented in:

- #24855

and something similar for `categorical_features` in:

- #24889

but we still need to do the same for `interaction_cst`, maybe after #24849 has been reviewed and merged.

Labels: Enhancement
Make it possible to specify interaction_cst and monotonic_cst with feature names.

### Describe the workflow you want to enable

Instead of passing an array of monotonicity constraints (`-1` for a decrease constraint, `+1` for an increase constraint or `0` for no constraint) specified by feature positions in the training set, it would be more convenient to pass a `dict` to pass constraints spec only for the required feature names (when those are available as `str` values in the dataset columns). For instance

```python
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor

X, y = load_diabetes(return_X_y=True, as_frame=True)

reg = HistGradientBoostingRegressor(
    monotonic_cst={"bmi": +1, "s3": -1}
)
reg.fit(X, y)
```

Not that here X has column names because it is a pandas dataframe.

See #24845 for a similar feature for `interaction_cst` by passing a list of tuple of `str` names instead.

### Describe your proposed solution

This requires updating the `fit` method, docstring and examples to accept a dict of constraints with feature names as keys.

If `feature_names_in_` is not defined in `fit`, then a value error with a helpful error message must be raised.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

Once #13649 is finalized and merged, a similar treatment should be adapted to it for the sake of consistency.

COMMENT:
I guess this can be closed with #24855, #24889 and #24849 merged.

Labels: Enhancement
"X does not have valid feature names" when training on DataFrame input with MLP

### Describe the bug

Bug happens only when early_stopping option is True.
Looks like `y_val` and `y` inside of `_fit()` training loop are ndarrays, but model detects column names of input `pandas.DataFrame` on `self._validate_input` step.


### Steps/Code to Reproduce

```python
from sklearn.neural_network import MLPClassifier, MLPRegressor
import pandas as pd

X = pd.DataFrame(data=[[i, i] for i in range(10)], columns=['colname_a', 'colname_b'])
y = pd.DataFrame(data=[[1] for i in range(10)], columns=['colname_y'])

print('training classifier')
model = MLPClassifier(
    early_stopping=True,
    validation_fraction=0.2
)
model.fit(X, y['colname_y'])

print('training regressor')

model = MLPRegressor(
    early_stopping=True,
    validation_fraction=0.2
)
model.fit(X, y['colname_y'])
```

### Expected Results

No messages like "UserWarning: X does not have valid feature names, but MLPClassifier was fitted with feature names"

### Actual Results

multiple messages like
```
...venv/lib/python3.10/site-packages/sklearn/base.py:450: UserWarning: X does not have valid feature names, but MLPClassifier was fitted with feature names
  warnings.warn(
```

### Versions

```shell
System:
    python: 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0]
executable: /home/usopp/sinp/mineralogy-2022/main/venv/bin/python
   machine: Linux-5.15.0-52-generic-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.1.3
          pip: 22.2.2
   setuptools: 62.3.4
        numpy: 1.23.3
        scipy: 1.9.1
       Cython: None
       pandas: 1.5.0
   matplotlib: 3.6.0
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /home/usopp/sinp/mineralogy-2022/main/venv/lib/python3.10/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
        version: None
    num_threads: 12

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/usopp/sinp/mineralogy-2022/main/venv/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-742d56dc.3.20.so
        version: 0.3.20
threading_layer: pthreads
   architecture: Haswell
    num_threads: 12

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/usopp/sinp/mineralogy-2022/main/venv/lib/python3.10/site-packages/scipy.libs/libopenblasp-r0-9f9f5dbc.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: Haswell
    num_threads: 12
```

COMMENT:
The column names got lost by the time`train_test_split` is called which is used to create the validation dataset. The problem then raises its head later when the accuracy score is computed, during `fit_stochastic`. Here `predict()` is called, which checks if the estimator was fitted with feature names and sees that the `X` passed in doesn't have feature names -> warning is raised.

Labels: Bug
"X does not have valid feature names" when training on DataFrame input with MLP

### Describe the bug

Bug happens only when early_stopping option is True.
Looks like `y_val` and `y` inside of `_fit()` training loop are ndarrays, but model detects column names of input `pandas.DataFrame` on `self._validate_input` step.


### Steps/Code to Reproduce

```python
from sklearn.neural_network import MLPClassifier, MLPRegressor
import pandas as pd

X = pd.DataFrame(data=[[i, i] for i in range(10)], columns=['colname_a', 'colname_b'])
y = pd.DataFrame(data=[[1] for i in range(10)], columns=['colname_y'])

print('training classifier')
model = MLPClassifier(
    early_stopping=True,
    validation_fraction=0.2
)
model.fit(X, y['colname_y'])

print('training regressor')

model = MLPRegressor(
    early_stopping=True,
    validation_fraction=0.2
)
model.fit(X, y['colname_y'])
```

### Expected Results

No messages like "UserWarning: X does not have valid feature names, but MLPClassifier was fitted with feature names"

### Actual Results

multiple messages like
```
...venv/lib/python3.10/site-packages/sklearn/base.py:450: UserWarning: X does not have valid feature names, but MLPClassifier was fitted with feature names
  warnings.warn(
```

### Versions

```shell
System:
    python: 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0]
executable: /home/usopp/sinp/mineralogy-2022/main/venv/bin/python
   machine: Linux-5.15.0-52-generic-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.1.3
          pip: 22.2.2
   setuptools: 62.3.4
        numpy: 1.23.3
        scipy: 1.9.1
       Cython: None
       pandas: 1.5.0
   matplotlib: 3.6.0
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /home/usopp/sinp/mineralogy-2022/main/venv/lib/python3.10/site-packages/scikit_learn.libs/libgomp-a34b3233.so.1.0.0
        version: None
    num_threads: 12

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/usopp/sinp/mineralogy-2022/main/venv/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-742d56dc.3.20.so
        version: 0.3.20
threading_layer: pthreads
   architecture: Haswell
    num_threads: 12

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /home/usopp/sinp/mineralogy-2022/main/venv/lib/python3.10/site-packages/scipy.libs/libopenblasp-r0-9f9f5dbc.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: Haswell
    num_threads: 12
```

COMMENT:
I'm taking a look at this.

Labels: Bug
Add user friendly string options for interaction constraints in HistGradientBoosting*

### Describe the workflow you want to enable

```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst="no_interactions"
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst="pairwise"
)
```

instead of
```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst=[[i] for i in range(X_train.shape[1])]
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst=list(itertools.combinations(range(n_features), 2))
)
```



### Describe your proposed solution

- [x] `"no_interactions"` is straight forward.
- [x] `"pairwise"` expands to a list that is quadratic in number of features. It might be more memory efficient to use generators internally.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This was proposed as follow-up in https://github.com/scikit-learn/scikit-learn/pull/21020#issuecomment-951233850.

COMMENT:
Hi,

If no one is taking it I can take this issue. I have to make a contribution as part of one of my lectures at university so I'd be grateful for letting me do it. 

However, perhaps I need more explanation. I've just checked the doc of HistGradientBoostingRegressor and there is no such argument as interaction_cst. So you would like to add this parameter and link the key word "no_interactions" or "pairwise" to what you showed in the part instead of. Am I correct? Perhaps you could describe a bit what this interaction means for this case.

Let me know if I got it right and if I can take this issue. (don't hesitate to tell me if this will be too hard for a beginner) Thanks.

Labels: New Feature, module:ensemble
Add user friendly string options for interaction constraints in HistGradientBoosting*

### Describe the workflow you want to enable

```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst="no_interactions"
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst="pairwise"
)
```

instead of
```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst=[[i] for i in range(X_train.shape[1])]
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst=list(itertools.combinations(range(n_features), 2))
)
```



### Describe your proposed solution

- [x] `"no_interactions"` is straight forward.
- [x] `"pairwise"` expands to a list that is quadratic in number of features. It might be more memory efficient to use generators internally.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This was proposed as follow-up in https://github.com/scikit-learn/scikit-learn/pull/21020#issuecomment-951233850.

COMMENT:
@mzugravu Have a look at the linked PR. Interaction constraints are a new feature that will be released in 1.2. I split this issue into 2 parts. The first part `"no_interactions"` is the by far easier one.
But if this is your first contribution, I suggest searching for issues with label "good first issue" (or "easy").

Labels: New Feature, module:ensemble
Add user friendly string options for interaction constraints in HistGradientBoosting*

### Describe the workflow you want to enable

```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst="no_interactions"
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst="pairwise"
)
```

instead of
```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst=[[i] for i in range(X_train.shape[1])]
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst=list(itertools.combinations(range(n_features), 2))
)
```



### Describe your proposed solution

- [x] `"no_interactions"` is straight forward.
- [x] `"pairwise"` expands to a list that is quadratic in number of features. It might be more memory efficient to use generators internally.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This was proposed as follow-up in https://github.com/scikit-learn/scikit-learn/pull/21020#issuecomment-951233850.

COMMENT:
Ok, thank you. I think I will keep searching it might be too hard for me.

Labels: New Feature, module:ensemble
Add user friendly string options for interaction constraints in HistGradientBoosting*

### Describe the workflow you want to enable

```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst="no_interactions"
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst="pairwise"
)
```

instead of
```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst=[[i] for i in range(X_train.shape[1])]
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst=list(itertools.combinations(range(n_features), 2))
)
```



### Describe your proposed solution

- [x] `"no_interactions"` is straight forward.
- [x] `"pairwise"` expands to a list that is quadratic in number of features. It might be more memory efficient to use generators internally.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This was proposed as follow-up in https://github.com/scikit-learn/scikit-learn/pull/21020#issuecomment-951233850.

COMMENT:
I'll take a look at this

Labels: New Feature, module:ensemble
Add user friendly string options for interaction constraints in HistGradientBoosting*

### Describe the workflow you want to enable

```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst="no_interactions"
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst="pairwise"
)
```

instead of
```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst=[[i] for i in range(X_train.shape[1])]
)

model_pairwise_interactions = HistGradientBoostingRegressor(
    interaction_cst=list(itertools.combinations(range(n_features), 2))
)
```



### Describe your proposed solution

- [x] `"no_interactions"` is straight forward.
- [x] `"pairwise"` expands to a list that is quadratic in number of features. It might be more memory efficient to use generators internally.

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

This was proposed as follow-up in https://github.com/scikit-learn/scikit-learn/pull/21020#issuecomment-951233850.

COMMENT:
And maybe also (possibly in a follow-up PR) using the input feature names of the model when available:


```python
model_no_interactions = HistGradientBoostingRegressor(
    interaction_cst=[
        ("name_of_feature_0", "name_of_feature_42"),
        ("name_of_feature_0", "name_of_feature_1", "name_of_feature_2"),
    ]
)
```

Labels: New Feature, module:ensemble