Talip7/scikit-learn-issues-multilabel huggingface dataset:
Installing from source issue

When following the guidelines for **installing scikit-learn from source** (https://scikit-learn.org/dev/developers/advanced_installation.html#building-from-source), I encountered the a problem at step 5:

```bash
pip install -v --no-use-pep517 --no-build-isolation -e .
```

which leads to the following error:

```bash
Using pip 24.0 from /Users/josephbarbier/opt/anaconda3/envs/sklearn-dev/lib/python3.12/site-packages/pip (python 3.12)
Obtaining file:///Users/josephbarbier/Desktop/scikit-learn
ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of mesonpy in pyproject.toml
```

I also tried:

```bash
pip install -v -e .
```

and then I get (at the end):

```bash
Successfully built scikit-learn
Installing collected packages: threadpoolctl, joblib, scikit-learn
Successfully installed joblib-1.3.2 scikit-learn-1.5.dev0 threadpoolctl-3.4.0
```

But then I run:

```bash
python -c "import sklearn; sklearn.show_versions()"
```

I get:

```bash
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/site-packages/_scikit_learn_editable_loader.py", line 271, in find_spec
    tree = self.rebuild()
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/site-packages/_scikit_learn_editable_loader.py", line 312, in rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=stdout, check=True)
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 1837, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/m2/jfzxyg4s0xz3jyw5f94r7tcm0000gn/T/pip-build-env-kba2z47e/normal/bin/ninja'
```

### Additional context

- `conda list` includes both `compilers` and `llvm-openmp`
- both `conda` and `pip` guides lead to the same error
- macOS Sonoma 14.4
- `Python 3.9.19` and `pip 24.0`

### Suggest a potential alternative/fix

_No response_

COMMENT:
Or even do not document the legacy/setuptools version.

Labels: Documentation
Installing from source issue

When following the guidelines for **installing scikit-learn from source** (https://scikit-learn.org/dev/developers/advanced_installation.html#building-from-source), I encountered the a problem at step 5:

```bash
pip install -v --no-use-pep517 --no-build-isolation -e .
```

which leads to the following error:

```bash
Using pip 24.0 from /Users/josephbarbier/opt/anaconda3/envs/sklearn-dev/lib/python3.12/site-packages/pip (python 3.12)
Obtaining file:///Users/josephbarbier/Desktop/scikit-learn
ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of mesonpy in pyproject.toml
```

I also tried:

```bash
pip install -v -e .
```

and then I get (at the end):

```bash
Successfully built scikit-learn
Installing collected packages: threadpoolctl, joblib, scikit-learn
Successfully installed joblib-1.3.2 scikit-learn-1.5.dev0 threadpoolctl-3.4.0
```

But then I run:

```bash
python -c "import sklearn; sklearn.show_versions()"
```

I get:

```bash
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/site-packages/_scikit_learn_editable_loader.py", line 271, in find_spec
    tree = self.rebuild()
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/site-packages/_scikit_learn_editable_loader.py", line 312, in rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=stdout, check=True)
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 1837, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/m2/jfzxyg4s0xz3jyw5f94r7tcm0000gn/T/pip-build-env-kba2z47e/normal/bin/ninja'
```

### Additional context

- `conda list` includes both `compilers` and `llvm-openmp`
- both `conda` and `pip` guides lead to the same error
- macOS Sonoma 14.4
- `Python 3.9.19` and `pip 24.0`

### Suggest a potential alternative/fix

_No response_

COMMENT:
@JosephBARBIERDARNAL thanks for the report, can you please confirm that https://github.com/scikit-learn/scikit-learn/issues/28748#issuecomment-2031826779 fixes the problem you encountered?

Labels: Documentation
Installing from source issue

When following the guidelines for **installing scikit-learn from source** (https://scikit-learn.org/dev/developers/advanced_installation.html#building-from-source), I encountered the a problem at step 5:

```bash
pip install -v --no-use-pep517 --no-build-isolation -e .
```

which leads to the following error:

```bash
Using pip 24.0 from /Users/josephbarbier/opt/anaconda3/envs/sklearn-dev/lib/python3.12/site-packages/pip (python 3.12)
Obtaining file:///Users/josephbarbier/Desktop/scikit-learn
ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of mesonpy in pyproject.toml
```

I also tried:

```bash
pip install -v -e .
```

and then I get (at the end):

```bash
Successfully built scikit-learn
Installing collected packages: threadpoolctl, joblib, scikit-learn
Successfully installed joblib-1.3.2 scikit-learn-1.5.dev0 threadpoolctl-3.4.0
```

But then I run:

```bash
python -c "import sklearn; sklearn.show_versions()"
```

I get:

```bash
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/site-packages/_scikit_learn_editable_loader.py", line 271, in find_spec
    tree = self.rebuild()
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/site-packages/_scikit_learn_editable_loader.py", line 312, in rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=stdout, check=True)
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 1837, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/m2/jfzxyg4s0xz3jyw5f94r7tcm0000gn/T/pip-build-env-kba2z47e/normal/bin/ninja'
```

### Additional context

- `conda list` includes both `compilers` and `llvm-openmp`
- both `conda` and `pip` guides lead to the same error
- macOS Sonoma 14.4
- `Python 3.9.19` and `pip 24.0`

### Suggest a potential alternative/fix

_No response_

COMMENT:
Yes, I think we should update the documentation to remove the "Install with meson" section and modify the "default" section to contain the correct instructions. I have a 50% done PR for that, but then time off and Easter happened.

Labels: Documentation
Installing from source issue

When following the guidelines for **installing scikit-learn from source** (https://scikit-learn.org/dev/developers/advanced_installation.html#building-from-source), I encountered the a problem at step 5:

```bash
pip install -v --no-use-pep517 --no-build-isolation -e .
```

which leads to the following error:

```bash
Using pip 24.0 from /Users/josephbarbier/opt/anaconda3/envs/sklearn-dev/lib/python3.12/site-packages/pip (python 3.12)
Obtaining file:///Users/josephbarbier/Desktop/scikit-learn
ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of mesonpy in pyproject.toml
```

I also tried:

```bash
pip install -v -e .
```

and then I get (at the end):

```bash
Successfully built scikit-learn
Installing collected packages: threadpoolctl, joblib, scikit-learn
Successfully installed joblib-1.3.2 scikit-learn-1.5.dev0 threadpoolctl-3.4.0
```

But then I run:

```bash
python -c "import sklearn; sklearn.show_versions()"
```

I get:

```bash
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 982, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 925, in _find_spec
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/site-packages/_scikit_learn_editable_loader.py", line 271, in find_spec
    tree = self.rebuild()
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/site-packages/_scikit_learn_editable_loader.py", line 312, in rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=stdout, check=True)
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/josephbarbier/opt/anaconda3/envs/sklearn-env/lib/python3.9/subprocess.py", line 1837, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/m2/jfzxyg4s0xz3jyw5f94r7tcm0000gn/T/pip-build-env-kba2z47e/normal/bin/ninja'
```

### Additional context

- `conda list` includes both `compilers` and `llvm-openmp`
- both `conda` and `pip` guides lead to the same error
- macOS Sonoma 14.4
- `Python 3.9.19` and `pip 24.0`

### Suggest a potential alternative/fix

_No response_

COMMENT:
I can confirm that this fixed the problem for me! Thanks!

Labels: Documentation
Please provide MAPE formula in documentation

### Describe the issue linked to the documentation

It is a bit unclear right now from the documentation if the formula used for MAPE= |y_true - y_pred|/y_pred *100/N or  |y_true - y_pred|/y_pred *1/N, however on checking the code we realize it is the latter.

### Suggest a potential alternative/fix 

Please include the formula in documentation

COMMENT:
Already provided in the user guide: https://scikit-learn.org/stable/modules/model_evaluation.html#mean-absolute-percentage-error

Labels: Documentation, Needs Triage
Docs say parameter sample_weight of LinearRegression.fit must be array but number is also valid

### Describe the issue linked to the documentation

The documentation page for the `fit` method of the `LinearRegression` class mentions that the `sample_weight` parameter must be of type `array_like` or `None` ([docs](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression.fit)). However this is not entirely true since we can also pass `float` or `int` for this parameter. Floats or ints get transformed into an array of that same value repeating n times. Code snippet here:
https://github.com/scikit-learn/scikit-learn/blob/f59c50301bc725fe3da75ac3b5e8614ff9a26f98/sklearn/utils/validation.py#L2000-L2003
This makes it that a sample weight of `float` or `int` is essentially equal to `None` since they all have the same relative weight (not sure if I'm overseeing something, but could not think of any case where a float or int for `sample_weight` could be meaningful).

### Suggest a potential alternative/fix

I see two possible fixes:
- Change the documentation to address the fact that numbers are valid values for `sample_weight` however they have no effect since there is no difference in the relative weight of the samples.
- Change the code so that an error or warning is raised if the `sample_weight` parameter is a `float` or an `int`.

COMMENT:
Indeed, PR welcome to fix the documentation.

Labels: Documentation, Needs Decision
Docs say parameter sample_weight of LinearRegression.fit must be array but number is also valid

### Describe the issue linked to the documentation

The documentation page for the `fit` method of the `LinearRegression` class mentions that the `sample_weight` parameter must be of type `array_like` or `None` ([docs](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression.fit)). However this is not entirely true since we can also pass `float` or `int` for this parameter. Floats or ints get transformed into an array of that same value repeating n times. Code snippet here:
https://github.com/scikit-learn/scikit-learn/blob/f59c50301bc725fe3da75ac3b5e8614ff9a26f98/sklearn/utils/validation.py#L2000-L2003
This makes it that a sample weight of `float` or `int` is essentially equal to `None` since they all have the same relative weight (not sure if I'm overseeing something, but could not think of any case where a float or int for `sample_weight` could be meaningful).

### Suggest a potential alternative/fix

I see two possible fixes:
- Change the documentation to address the fact that numbers are valid values for `sample_weight` however they have no effect since there is no difference in the relative weight of the samples.
- Change the code so that an error or warning is raised if the `sample_weight` parameter is a `float` or an `int`.

COMMENT:
> Indeed, PR welcome to fix the documentation.

Ok, will start working on it later today

Labels: Documentation, Needs Decision
Docs say parameter sample_weight of LinearRegression.fit must be array but number is also valid

### Describe the issue linked to the documentation

The documentation page for the `fit` method of the `LinearRegression` class mentions that the `sample_weight` parameter must be of type `array_like` or `None` ([docs](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression.fit)). However this is not entirely true since we can also pass `float` or `int` for this parameter. Floats or ints get transformed into an array of that same value repeating n times. Code snippet here:
https://github.com/scikit-learn/scikit-learn/blob/f59c50301bc725fe3da75ac3b5e8614ff9a26f98/sklearn/utils/validation.py#L2000-L2003
This makes it that a sample weight of `float` or `int` is essentially equal to `None` since they all have the same relative weight (not sure if I'm overseeing something, but could not think of any case where a float or int for `sample_weight` could be meaningful).

### Suggest a potential alternative/fix

I see two possible fixes:
- Change the documentation to address the fact that numbers are valid values for `sample_weight` however they have no effect since there is no difference in the relative weight of the samples.
- Change the code so that an error or warning is raised if the `sample_weight` parameter is a `float` or an `int`.

COMMENT:
Given that providing the same value for all samples is a bit weird, does anyone remember why this is supported in the first place?

Labels: Documentation, Needs Decision
Docs say parameter sample_weight of LinearRegression.fit must be array but number is also valid

### Describe the issue linked to the documentation

The documentation page for the `fit` method of the `LinearRegression` class mentions that the `sample_weight` parameter must be of type `array_like` or `None` ([docs](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression.fit)). However this is not entirely true since we can also pass `float` or `int` for this parameter. Floats or ints get transformed into an array of that same value repeating n times. Code snippet here:
https://github.com/scikit-learn/scikit-learn/blob/f59c50301bc725fe3da75ac3b5e8614ff9a26f98/sklearn/utils/validation.py#L2000-L2003
This makes it that a sample weight of `float` or `int` is essentially equal to `None` since they all have the same relative weight (not sure if I'm overseeing something, but could not think of any case where a float or int for `sample_weight` could be meaningful).

### Suggest a potential alternative/fix

I see two possible fixes:
- Change the documentation to address the fact that numbers are valid values for `sample_weight` however they have no effect since there is no difference in the relative weight of the samples.
- Change the code so that an error or warning is raised if the `sample_weight` parameter is a `float` or an `int`.

COMMENT:
> Given that providing the same value for all samples is a bit weird, does anyone remember why this is supported in the first place?

I guess we need to edit the code to raise an error and re-run the tests to check if passing a scalar int or float is used anywhere in our code base, and in particular as part of public facing API.

If it's not used anywhere, maybe we can deprecate this.

Labels: Documentation, Needs Decision
Docs say parameter sample_weight of LinearRegression.fit must be array but number is also valid

### Describe the issue linked to the documentation

The documentation page for the `fit` method of the `LinearRegression` class mentions that the `sample_weight` parameter must be of type `array_like` or `None` ([docs](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression.fit)). However this is not entirely true since we can also pass `float` or `int` for this parameter. Floats or ints get transformed into an array of that same value repeating n times. Code snippet here:
https://github.com/scikit-learn/scikit-learn/blob/f59c50301bc725fe3da75ac3b5e8614ff9a26f98/sklearn/utils/validation.py#L2000-L2003
This makes it that a sample weight of `float` or `int` is essentially equal to `None` since they all have the same relative weight (not sure if I'm overseeing something, but could not think of any case where a float or int for `sample_weight` could be meaningful).

### Suggest a potential alternative/fix

I see two possible fixes:
- Change the documentation to address the fact that numbers are valid values for `sample_weight` however they have no effect since there is no difference in the relative weight of the samples.
- Change the code so that an error or warning is raised if the `sample_weight` parameter is a `float` or an `int`.

COMMENT:
My guess is that `_check_sample_weight` supports int/float weights because it is used across many different estimators. For some of them it might make sense to use uniform integer weights. So we'd have to specifically check in `LinearRegression` if someone passed int/float weights.

Or maybe we leave this undocumented and don't introduce a check. Nothing bad/incorrect happens if you pass a int/float as weight, it is just unusual. Maybe we need to balance this with helping users who passed a int/float by mistake. For those it would be useful to raise an error.

Labels: Documentation, Needs Decision
Docs say parameter sample_weight of LinearRegression.fit must be array but number is also valid

### Describe the issue linked to the documentation

The documentation page for the `fit` method of the `LinearRegression` class mentions that the `sample_weight` parameter must be of type `array_like` or `None` ([docs](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression.fit)). However this is not entirely true since we can also pass `float` or `int` for this parameter. Floats or ints get transformed into an array of that same value repeating n times. Code snippet here:
https://github.com/scikit-learn/scikit-learn/blob/f59c50301bc725fe3da75ac3b5e8614ff9a26f98/sklearn/utils/validation.py#L2000-L2003
This makes it that a sample weight of `float` or `int` is essentially equal to `None` since they all have the same relative weight (not sure if I'm overseeing something, but could not think of any case where a float or int for `sample_weight` could be meaningful).

### Suggest a potential alternative/fix

I see two possible fixes:
- Change the documentation to address the fact that numbers are valid values for `sample_weight` however they have no effect since there is no difference in the relative weight of the samples.
- Change the code so that an error or warning is raised if the `sample_weight` parameter is a `float` or an `int`.

COMMENT:
Following @betatim's point that this technically works, but was probably a mistake, an intermediate solution could be to just warn for now:

```python
Warning: a single number {sample_weight} was provided as "sample_weight", each sample will receive the same weight of {sample_weight}.
```

Labels: Documentation, Needs Decision
Docs say parameter sample_weight of LinearRegression.fit must be array but number is also valid

### Describe the issue linked to the documentation

The documentation page for the `fit` method of the `LinearRegression` class mentions that the `sample_weight` parameter must be of type `array_like` or `None` ([docs](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression.fit)). However this is not entirely true since we can also pass `float` or `int` for this parameter. Floats or ints get transformed into an array of that same value repeating n times. Code snippet here:
https://github.com/scikit-learn/scikit-learn/blob/f59c50301bc725fe3da75ac3b5e8614ff9a26f98/sklearn/utils/validation.py#L2000-L2003
This makes it that a sample weight of `float` or `int` is essentially equal to `None` since they all have the same relative weight (not sure if I'm overseeing something, but could not think of any case where a float or int for `sample_weight` could be meaningful).

### Suggest a potential alternative/fix

I see two possible fixes:
- Change the documentation to address the fact that numbers are valid values for `sample_weight` however they have no effect since there is no difference in the relative weight of the samples.
- Change the code so that an error or warning is raised if the `sample_weight` parameter is a `float` or an `int`.

COMMENT:
To me keeping support for float can be handy if we want to extend our tests for consistent sample weight behavior as discussed in e.g. https://github.com/scikit-learn/scikit-learn/issues/15657. But it's not a big problem since we just pass an array with all equal elements.

There a use case where I can think supporting a float is convenient: if you want to learn on minibatches where for some reason you want to apply the same weight for all elements in a batch but different between batches. Again, doable by passing an array with all equal elements, but less convenient.

Labels: Documentation, Needs Decision