Skip to content

DOC improve User Guide on Linear Models - intro and OLS - #35215

Merged
lucyleeow merged 9 commits into
scikit-learn:mainfrom
lorentzenchr:ug_linear_models_ols
Nov 4, 2026
Merged

lucyleeow merged 9 commits into
scikit-learn:mainfrom
lorentzenchr:ug_linear_models_ols

Conversation

@lorentzenchr

Copy link
Copy Markdown
Member

Reference Issues/PRs

Contributes to #33537.

What does this implement/fix? Explain your changes.

This PR improves the user guide on linear models:

  • intro
  • OLS

AI usage disclosure

I used AI assistance for:

  • Research and understanding

Any other comments?

@cakedev0 cakedev0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a good improvement I think 👍

Some nits below, but overall LGTM.

Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Resolved

@cakedev0 cakedev0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@cakedev0 cakedev0 added the Waiting for Second Reviewer First reviewer is done, need a second one! label Oct 27, 2026
@lorentzenchr

Copy link
Copy Markdown
Member Author

@virchan @lucyleeow Are you interested in this one?

@lucyleeow lucyleeow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping, this was a nice read and some very nice improvements! Some nits only.

Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Outdated

such that it includes the intercept :math:`w_0`. You might also think of :math:`X` as
the data matrix extended by a column of ones. In the implementation, scikit-learn
tries to avoid as much as possible to build this extended matrix explicitly.

@lucyleeow lucyleeow Nov 3, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My naive understanding for why we avoid building the extended matrix explicitly is for speed/memory and it does not make sense to include intercepts in regularization.
(If that's on the right track) Maybe we could link the ideas more directly (e.g., we don't build the extended matrix because....)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence was also unclear to me. Us not building the extended matrix "explicitly" could also be interpreted as we do use it, but implicitly, which my agent says is in fact done by centering. What about mentioning centering here as the approach taken in most cases and why it is used instead of the intercept column?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added "which would more than double the memory consumption".

Hint: The centering trick does not work for LogisticRegression and other GLMs (only for OLS, Ridge, Lasso, ..).

Comment thread doc/modules/linear_model.rst Resolved
Comment thread doc/modules/linear_model.rst Resolved
cakedev0 added a commit to cakedev0/my-scikit-learn-backlog that referenced this pull request Nov 3, 2026
todo: move [sklearn#35216](scikit-learn/scikit-learn#35216) from Now to Waiting, the test was already there, approved by lesteve with auto-merge
add: Trees: get [sklearn#34554](scikit-learn/scikit-learn#34554) merged (recursion PDP on categorical features; approved)
add: Threads: review [sklearn#34729](scikit-learn/scikit-learn#34729) (inference methods don't modify the estimator; ev-br on the SplineTransformer mutation)
todo: lucyleeow approved [sklearn#35215](scikit-learn/scikit-learn#35215)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lucyleeow

Copy link
Copy Markdown
Member

@lorentzenchr happy for me to merge now?

@lorentzenchr

Copy link
Copy Markdown
Member Author

@lorentzenchr happy for me to merge now?

In scikit-learn, it is habit that a reviewer merges.

@lucyleeow
lucyleeow merged commit 3c5e5ef into scikit-learn:main Nov 4, 2026
38 checks passed
@lorentzenchr
lorentzenchr deleted the ug_linear_models_ols branch November 4, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants