Talip7/scikit-learn-issues-multilabel huggingface dataset:
Setting min_samples_split=1 in DecisionTreeClassifier does not raise exception

### Describe the bug

If `min_samples_split` is set to 1, an exception should be raised according to the paramter's constraints:

https://github.com/scikit-learn/scikit-learn/blob/e2e705021eb6c9f23f0972f119b56e37cd7567ef/sklearn/tree/_classes.py#L100-L103

However, `DecisionTreeClassifier` accepts `min_samples_split=1` without complaining.

With scikit-survival 1.0, this raises an exception as expected:
```
ValueError: min_samples_split == 1, must be >= 2.
```

I suspect that this has to do with the Intervals of the constraints overlapping. `min_samples_split=1` satisfies the `Real` constraint, whereas the `Integral` constraint should have precedence.

### Steps/Code to Reproduce

```python
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)
t = DecisionTreeClassifier(min_samples_split=1)
t.fit(X, y)
```

### Expected Results

```
sklearn.utils._param_validation.InvalidParameterError: The 'min_samples_split' parameter of DecisionTreeClassifier must be an int in the range [2, inf) or a float in the range (0.0, 1.0]. Got 1 instead.
```

### Actual Results

No exception is raised.

### Versions

```shell
System:
    python: 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:26:04) [GCC 10.4.0]
executable: /…/bin/python
   machine: Linux-6.1.6-100.fc36.x86_64-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.3.dev0
          pip: 22.2.2
   setuptools: 63.2.0
        numpy: 1.24.1
        scipy: 1.10.0
       Cython: None
       pandas: None
   matplotlib: None
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /…/lib/libgomp.so.1.0.0
        version: None
    num_threads: 16

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /…/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-15028c96.3.21.so
        version: 0.3.21
threading_layer: pthreads
   architecture: Zen
    num_threads: 16

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /…/lib/python3.10/site-packages/scipy.libs/libopenblasp-r0-41284840.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen
    num_threads: 16
```

COMMENT:
I think that this is on purpose. Otherwise, we would have used `closed="neither"` for the `Real` case and `1` is qualified as a `Real`.

At least this is not a regression since the code in the past would have failed and now we allow it to be considered as 100% of the train set.

If we exclude `1` it means that we don't accept both 100% and 1. I don't know if this is something that we want.

Labels: Bug, module:tree
Setting min_samples_split=1 in DecisionTreeClassifier does not raise exception

### Describe the bug

If `min_samples_split` is set to 1, an exception should be raised according to the paramter's constraints:

https://github.com/scikit-learn/scikit-learn/blob/e2e705021eb6c9f23f0972f119b56e37cd7567ef/sklearn/tree/_classes.py#L100-L103

However, `DecisionTreeClassifier` accepts `min_samples_split=1` without complaining.

With scikit-survival 1.0, this raises an exception as expected:
```
ValueError: min_samples_split == 1, must be >= 2.
```

I suspect that this has to do with the Intervals of the constraints overlapping. `min_samples_split=1` satisfies the `Real` constraint, whereas the `Integral` constraint should have precedence.

### Steps/Code to Reproduce

```python
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)
t = DecisionTreeClassifier(min_samples_split=1)
t.fit(X, y)
```

### Expected Results

```
sklearn.utils._param_validation.InvalidParameterError: The 'min_samples_split' parameter of DecisionTreeClassifier must be an int in the range [2, inf) or a float in the range (0.0, 1.0]. Got 1 instead.
```

### Actual Results

No exception is raised.

### Versions

```shell
System:
    python: 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:26:04) [GCC 10.4.0]
executable: /…/bin/python
   machine: Linux-6.1.6-100.fc36.x86_64-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.3.dev0
          pip: 22.2.2
   setuptools: 63.2.0
        numpy: 1.24.1
        scipy: 1.10.0
       Cython: None
       pandas: None
   matplotlib: None
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /…/lib/libgomp.so.1.0.0
        version: None
    num_threads: 16

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /…/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-15028c96.3.21.so
        version: 0.3.21
threading_layer: pthreads
   architecture: Zen
    num_threads: 16

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /…/lib/python3.10/site-packages/scipy.libs/libopenblasp-r0-41284840.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen
    num_threads: 16
```

COMMENT:
Note that with sklearn 1.0, `min_samples_split=1.0` does not raise an exception, only `min_samples_split=1`.

Labels: Bug, module:tree
Setting min_samples_split=1 in DecisionTreeClassifier does not raise exception

### Describe the bug

If `min_samples_split` is set to 1, an exception should be raised according to the paramter's constraints:

https://github.com/scikit-learn/scikit-learn/blob/e2e705021eb6c9f23f0972f119b56e37cd7567ef/sklearn/tree/_classes.py#L100-L103

However, `DecisionTreeClassifier` accepts `min_samples_split=1` without complaining.

With scikit-survival 1.0, this raises an exception as expected:
```
ValueError: min_samples_split == 1, must be >= 2.
```

I suspect that this has to do with the Intervals of the constraints overlapping. `min_samples_split=1` satisfies the `Real` constraint, whereas the `Integral` constraint should have precedence.

### Steps/Code to Reproduce

```python
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_iris

X, y = load_iris(return_X_y=True)
t = DecisionTreeClassifier(min_samples_split=1)
t.fit(X, y)
```

### Expected Results

```
sklearn.utils._param_validation.InvalidParameterError: The 'min_samples_split' parameter of DecisionTreeClassifier must be an int in the range [2, inf) or a float in the range (0.0, 1.0]. Got 1 instead.
```

### Actual Results

No exception is raised.

### Versions

```shell
System:
    python: 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:26:04) [GCC 10.4.0]
executable: /…/bin/python
   machine: Linux-6.1.6-100.fc36.x86_64-x86_64-with-glibc2.35

Python dependencies:
      sklearn: 1.3.dev0
          pip: 22.2.2
   setuptools: 63.2.0
        numpy: 1.24.1
        scipy: 1.10.0
       Cython: None
       pandas: None
   matplotlib: None
       joblib: 1.2.0
threadpoolctl: 3.1.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
         prefix: libgomp
       filepath: /…/lib/libgomp.so.1.0.0
        version: None
    num_threads: 16

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /…/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-15028c96.3.21.so
        version: 0.3.21
threading_layer: pthreads
   architecture: Zen
    num_threads: 16

       user_api: blas
   internal_api: openblas
         prefix: libopenblas
       filepath: /…/lib/python3.10/site-packages/scipy.libs/libopenblasp-r0-41284840.3.18.so
        version: 0.3.18
threading_layer: pthreads
   architecture: Zen
    num_threads: 16
```

COMMENT:
Also note that `min_samples_split=1.0` and `min_samples_split=1` do not result in the same behavior:

https://github.com/scikit-learn/scikit-learn/blob/baefe83933df9abecc2c16769d42e52b2694a9c8/sklearn/tree/_classes.py#L257-L263

If `min_samples_split=1`, the actual `min_samples_split` is determine by `min_samples_leaf`:
```python
min_samples_split = max(min_samples_split, 2 * min_samples_leaf)
```

If `min_samples_split=1.0` and assuming there are more than 2 samples in the data, `min_samples_split = n_samples`:
```python
min_samples_split = int(ceil(self.min_samples_split * n_samples))
```

Labels: Bug, module:tree
Regression for wine dataset with pandas parser

From #25334, it seems that we have a regression for the pandas parser for the following dataset.

```python
from sklearn.datasets import fetch_openml

wine_reviews = fetch_openml(data_id=42074, as_frame=True, parser="pandas")

# pandas.errors.ParserError: Error tokenizing data. C error: Expected 10 fields in line 2, saw 15
```

COMMENT:
Are you tagging the right issue? Is this not because of the white space removal we did after the regression we found on the fairlearn side?

Labels: module:datasets, Needs Investigation
Regression for wine dataset with pandas parser

From #25334, it seems that we have a regression for the pandas parser for the following dataset.

```python
from sklearn.datasets import fetch_openml

wine_reviews = fetch_openml(data_id=42074, as_frame=True, parser="pandas")

# pandas.errors.ParserError: Error tokenizing data. C error: Expected 10 fields in line 2, saw 15
```

COMMENT:
It is still failing in `main` unfortunately. At least, the whitespace issue was not failing with a parsing error :). I will introspect the ARFF file. This is going to be fun :)

Labels: module:datasets, Needs Investigation
Regression for wine dataset with pandas parser

From #25334, it seems that we have a regression for the pandas parser for the following dataset.

```python
from sklearn.datasets import fetch_openml

wine_reviews = fetch_openml(data_id=42074, as_frame=True, parser="pandas")

# pandas.errors.ParserError: Error tokenizing data. C error: Expected 10 fields in line 2, saw 15
```

COMMENT:
/take

Labels: module:datasets, Needs Investigation
Regression for wine dataset with pandas parser

From #25334, it seems that we have a regression for the pandas parser for the following dataset.

```python
from sklearn.datasets import fetch_openml

wine_reviews = fetch_openml(data_id=42074, as_frame=True, parser="pandas")

# pandas.errors.ParserError: Error tokenizing data. C error: Expected 10 fields in line 2, saw 15
```

COMMENT:
In this file, strings are quoted with single quotes (i.e. `'`) while we always tested with double quotes (i.e. `"`). In addition, they use `\` as an escape character.

Here, it would require changing `quotechars` and `escapechar` in the `read_csv` file.

I see two potential PRs here:
- add a quote inference
- add the `escapechar` to the `read_csv` call and the possibility to overwrite the default parameter passed to `read_csv`.

Labels: module:datasets, Needs Investigation
Regression for wine dataset with pandas parser

From #25334, it seems that we have a regression for the pandas parser for the following dataset.

```python
from sklearn.datasets import fetch_openml

wine_reviews = fetch_openml(data_id=42074, as_frame=True, parser="pandas")

# pandas.errors.ParserError: Error tokenizing data. C error: Expected 10 fields in line 2, saw 15
```

COMMENT:
As for overwriting the kwargs to `read_csv`, I do not know how useful it would be. For example, I would not know to change `quotechars` and `escapechar` from the error message in https://github.com/scikit-learn/scikit-learn/issues/25478#issue-1556885584

It looks like ARFF accepts a range of quotechars and escapechars:

https://github.com/scikit-learn/scikit-learn/blob/4db04923a754b6a2defa1b172f55d492b85d165e/sklearn/externals/_arff.py#L166-L167

I think quote inference would be useful to be aligned with ARFF. Do you think it's safe to pass in `\` as the escape character all the time?

Labels: module:datasets, Needs Investigation
Regression for wine dataset with pandas parser

From #25334, it seems that we have a regression for the pandas parser for the following dataset.

```python
from sklearn.datasets import fetch_openml

wine_reviews = fetch_openml(data_id=42074, as_frame=True, parser="pandas")

# pandas.errors.ParserError: Error tokenizing data. C error: Expected 10 fields in line 2, saw 15
```

COMMENT:
> As for overwriting the kwargs to read_csv, I do not know how useful it would be.

It allows finding a way out when things go sideways but the user experience is terrible. Indeed, this is not a fix for this PR for sure.

> I think quote inference would be useful to be aligned with ARFF.

Yep, we should probably infer on the first line of the data.

> Do you think it's safe to pass in \ as the escape character all the time?

I think so but I am not 100% confident :)

Labels: module:datasets, Needs Investigation
Try to Implemenet the example but  error raise (TypeError: __init__() takes 1 positional argument but 3 were given)

### Describe the bug

I try to run the example of  NearestNeighbors which is given in the documentation 

```py
import numpy as np

 from sklearn.neighbors import NearestNeighbors
 samples = [[0, 0, 2], [1, 0, 0], [0, 0, 1]]


 neigh = NearestNeighbors(2, 0.4)
 neigh.fit(samples) 
```


it gives the error of **TypeError: __init__() takes 1 positional argument but 3 were given**

How to fix the issue ? is there any problem with [Documentation](http://lijiancheng0614.github.io/scikit-learn/modules/generated/sklearn.neighbors.NearestNeighbors.html)

is it need to be updated?


### Steps/Code to Reproduce

```py
import numpy as np

 from sklearn.neighbors import NearestNeighbors
 samples = [[0, 0, 2], [1, 0, 0], [0, 0, 1]]


 neigh = NearestNeighbors(2, 0.4)
 neigh.fit(samples) 
```

### Expected Results

it should be run 

### Actual Results

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-99-8edb6260b431>](https://localhost:8080/#) in <module>
----> 1 neigh = NearestNeighbors(2, 0.4)

TypeError: __init__() takes 1 positional argument but 3 were given
```

### Versions

```shell
System:
    python: 3.8.10 (default, Nov 14 2022, 12:59:47)  [GCC 9.4.0]
executable: /usr/bin/python3
   machine: Linux-5.10.147+-x86_64-with-glibc2.29

Python dependencies:
          pip: 22.0.4
   setuptools: 57.4.0
      sklearn: 1.0.2
        numpy: 1.21.6
        scipy: 1.7.3
       Cython: 0.29.33
       pandas: 1.3.5
   matplotlib: 3.2.2
       joblib: 1.2.0
threadpoolctl: 3.1.0
```

COMMENT:
Hi @106AbdulBasit, the documentation you're reffering to is not the official documentation and seems to not be up to date. Here's a link to the [official documentation](https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.NearestNeighbors.html#sklearn.neighbors.NearestNeighbors), where you'll notice that the parameters need to be passed as keyword parameters now.

Labels: Bug, Needs Triage
Try to Implemenet the example but  error raise (TypeError: __init__() takes 1 positional argument but 3 were given)

### Describe the bug

I try to run the example of  NearestNeighbors which is given in the documentation 

```py
import numpy as np

 from sklearn.neighbors import NearestNeighbors
 samples = [[0, 0, 2], [1, 0, 0], [0, 0, 1]]


 neigh = NearestNeighbors(2, 0.4)
 neigh.fit(samples) 
```


it gives the error of **TypeError: __init__() takes 1 positional argument but 3 were given**

How to fix the issue ? is there any problem with [Documentation](http://lijiancheng0614.github.io/scikit-learn/modules/generated/sklearn.neighbors.NearestNeighbors.html)

is it need to be updated?


### Steps/Code to Reproduce

```py
import numpy as np

 from sklearn.neighbors import NearestNeighbors
 samples = [[0, 0, 2], [1, 0, 0], [0, 0, 1]]


 neigh = NearestNeighbors(2, 0.4)
 neigh.fit(samples) 
```

### Expected Results

it should be run 

### Actual Results

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-99-8edb6260b431>](https://localhost:8080/#) in <module>
----> 1 neigh = NearestNeighbors(2, 0.4)

TypeError: __init__() takes 1 positional argument but 3 were given
```

### Versions

```shell
System:
    python: 3.8.10 (default, Nov 14 2022, 12:59:47)  [GCC 9.4.0]
executable: /usr/bin/python3
   machine: Linux-5.10.147+-x86_64-with-glibc2.29

Python dependencies:
          pip: 22.0.4
   setuptools: 57.4.0
      sklearn: 1.0.2
        numpy: 1.21.6
        scipy: 1.7.3
       Cython: 0.29.33
       pandas: 1.3.5
   matplotlib: 3.2.2
       joblib: 1.2.0
threadpoolctl: 3.1.0
```

COMMENT:
Oh, thank you for the response ,

Labels: Bug, Needs Triage
Try to Implemenet the example but  error raise (TypeError: __init__() takes 1 positional argument but 3 were given)

### Describe the bug

I try to run the example of  NearestNeighbors which is given in the documentation 

```py
import numpy as np

 from sklearn.neighbors import NearestNeighbors
 samples = [[0, 0, 2], [1, 0, 0], [0, 0, 1]]


 neigh = NearestNeighbors(2, 0.4)
 neigh.fit(samples) 
```


it gives the error of **TypeError: __init__() takes 1 positional argument but 3 were given**

How to fix the issue ? is there any problem with [Documentation](http://lijiancheng0614.github.io/scikit-learn/modules/generated/sklearn.neighbors.NearestNeighbors.html)

is it need to be updated?


### Steps/Code to Reproduce

```py
import numpy as np

 from sklearn.neighbors import NearestNeighbors
 samples = [[0, 0, 2], [1, 0, 0], [0, 0, 1]]


 neigh = NearestNeighbors(2, 0.4)
 neigh.fit(samples) 
```

### Expected Results

it should be run 

### Actual Results

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-99-8edb6260b431>](https://localhost:8080/#) in <module>
----> 1 neigh = NearestNeighbors(2, 0.4)

TypeError: __init__() takes 1 positional argument but 3 were given
```

### Versions

```shell
System:
    python: 3.8.10 (default, Nov 14 2022, 12:59:47)  [GCC 9.4.0]
executable: /usr/bin/python3
   machine: Linux-5.10.147+-x86_64-with-glibc2.29

Python dependencies:
          pip: 22.0.4
   setuptools: 57.4.0
      sklearn: 1.0.2
        numpy: 1.21.6
        scipy: 1.7.3
       Cython: 0.29.33
       pandas: 1.3.5
   matplotlib: 3.2.2
       joblib: 1.2.0
threadpoolctl: 3.1.0
```

COMMENT:
I am closing this issue because https://github.com/scikit-learn/scikit-learn/issues/25468#issuecomment-1401906992 answers the original question.

Labels: Bug, Needs Triage
HistGradientBoosting avoid data shuffling when early_stopping activated

hello, it would be useful if the _HistGradientBoostingRegressor_ or _HistGradientBoostingClassifier_ model had the ability to avoid data shuffling when using the _early_stopping_ and _validation_fraction_ parameters, since maintaining data order is a basic requirement in case you work with TimeSeries

  https://github.com/scikit-learn/scikit-learn/blob/98cf537f5/sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py#L427
```python
            if sample_weight is None:
                X_train, X_val, y_train, y_val = train_test_split(
                    X,
                    y,
                    test_size=self.validation_fraction,
                    stratify=stratify,
                    random_state=self._random_seed,
                )
                sample_weight_train = sample_weight_val = None
            else:
                # TODO: incorporate sample_weight in sampling here, as well as
                # stratify
                (
                    X_train,
                    X_val,
                    y_train,
                    y_val,
                    sample_weight_train,
                    sample_weight_val,
                ) = train_test_split(
                    X,
                    y,
                    sample_weight,
                    test_size=self.validation_fraction,
                    stratify=stratify,
                    random_state=self._random_seed,
                )
```


### Describe your proposed solution

it would be sufficient to add an additional parameter to control whether or not to shuffle the data

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

_No response_

COMMENT:
Indeed, it could even be considered a methodological bug since the obtained model will not be viable. I am not sure what is the best approach here to solve the issue. Adding `shuffle` is one but I recall that we thought about early-stopping when playing with callbacks (ping @jeremiedbb). Through the callbacks, we could provide a given train-test split that would be designed for the application purpose.

Labels: module:ensemble, Needs Decision - Include Feature
HistGradientBoosting avoid data shuffling when early_stopping activated

hello, it would be useful if the _HistGradientBoostingRegressor_ or _HistGradientBoostingClassifier_ model had the ability to avoid data shuffling when using the _early_stopping_ and _validation_fraction_ parameters, since maintaining data order is a basic requirement in case you work with TimeSeries

  https://github.com/scikit-learn/scikit-learn/blob/98cf537f5/sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py#L427
```python
            if sample_weight is None:
                X_train, X_val, y_train, y_val = train_test_split(
                    X,
                    y,
                    test_size=self.validation_fraction,
                    stratify=stratify,
                    random_state=self._random_seed,
                )
                sample_weight_train = sample_weight_val = None
            else:
                # TODO: incorporate sample_weight in sampling here, as well as
                # stratify
                (
                    X_train,
                    X_val,
                    y_train,
                    y_val,
                    sample_weight_train,
                    sample_weight_val,
                ) = train_test_split(
                    X,
                    y,
                    sample_weight,
                    test_size=self.validation_fraction,
                    stratify=stratify,
                    random_state=self._random_seed,
                )
```


### Describe your proposed solution

it would be sufficient to add an additional parameter to control whether or not to shuffle the data

### Describe alternatives you've considered, if relevant

_No response_

### Additional context

_No response_

COMMENT:
can I work on this one?

Labels: module:ensemble, Needs Decision - Include Feature