Repository: scikit-learn/scikit-learn
Pull request: DOC Linear regression doc update
<!--
Thanks for contributing a pull request! Please ensure you have taken a look at
the contribution guidelines: https://github.com/scikit-learn/scikit-learn/blob/main/CONTRIBUTING.md
-->

#### Reference Issues/PRs
Fixes #21254.
Related to #14228.

#### What does this implement/fix? Explain your changes.
By fitting a LinearRegression the n_jobs parameter can set the number of threads only in case of positive=True or in case of sp.issparse(X). In other cases the linalg.lstsq is called which can handle (M, K) shaped y and there is no parameter like n_jobs in this call.

Docstring is updated according to this.

Problem statement:
`n_jobs` parameter documentation in `LinearRegression`
### Describe the issue linked to the documentation

By fitting a `LinearRegression` the `n_jobs` parameter can set the number of threads only in case of `positive=True` or in case of `sp.issparse(X)`. In other cases the `linalg.lstsq` is called which can handle (M, K) shaped `y` and there is no parameter like `n_jobs` in this call.

So as i understand in the most of the usecases `n_jobs` will not affect the fitting. However i cant find this in documentation. 

### Suggest a potential alternative/fix

I think this fact should be added to the docs. What do you think?

Hints from issue discussion:
I agree the documentation can be improved here. Would you like to update a PR and update the docstring?
Sure!

Commit message: Apply suggestions from code review

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>

Patch to review:
diff --git a/sklearn/linear_model/_base.py b/sklearn/linear_model/_base.py
index 8b5102ecdd403..8a8c43819292e 100644
--- a/sklearn/linear_model/_base.py
+++ b/sklearn/linear_model/_base.py
@@ -536,10 +536,10 @@ class LinearRegression(MultiOutputMixin, RegressorMixin, LinearModel):
 
     n_jobs : int, default=None
         The number of jobs to use for the computation. This will only provide
-        speedup for n_targets > 1 and sufficient large problems.
-        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
-        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
-        for more details.
+        speedup in case of sufficient large problems if `X` is sparse or
+        `positive` is set to `True` and n_targets > 1. ``None`` means 1 unless
+        in a :obj:`joblib.parallel_backend` context. ``-1`` means using all
+        processors. See :term:`Glossary <n_jobs>` for more details.
 
     positive : bool, default=False
         When set to ``True``, forces the coefficients to be positive. This


Code review comments:
diff_hunk: @@ -536,10 +536,10 @@ class LinearRegression(MultiOutputMixin, RegressorMixin, LinearModel):
 
     n_jobs : int, default=None
         The number of jobs to use for the computation. This will only provide
-        speedup for n_targets > 1 and sufficient large problems.
-        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
-        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
-        for more details.
+        speedup in case of sufficient large problems if `X` is sparse or
+        `positive` is set to `True` and n_targets > 1. ``None`` means 1 unless
+        in a :obj:`joblib.parallel_backend` context. ``-1`` means using all
+        processors. See :term:`Glossary <n_jobs>` for more details.
path: sklearn/linear_model/_base.py
text: @user1:
Can it be further clarified? Currently, I understand the condition as:
```
	n_targets > 1 and (issparse(X) or positive)
```

```suggestion
        speedup in case of sufficiently large problems, that is if firstly
        `n_targets > 1` and secondly `X` is sparse or if `positive` is set
        to `True`. ``None`` means 1 unless in a
        :obj:`joblib.parallel_backend` context. ``-1`` means using all
        processors. See :term:`Glossary <n_jobs>` for more details.
```