Skip to content

[MRG+2] temporary fix for sparse ridge with intercept fitting - #5360

Merged
TomDLT merged 2 commits into
scikit-learn:masterfrom
TomDLT:sparseridge
Oct 13, 2015
Merged

TomDLT merged 2 commits into
scikit-learn:masterfrom
TomDLT:sparseridge

Conversation

@TomDLT

@TomDLT TomDLT commented Oct 7, 2015

Copy link
Copy Markdown
Member

Temporary fix for #4710, using 'sag' solver, that can directly fit the intercept.

If fit_intercept=True and X is sparse, then the solver is switch to 'sag'.

I am aware this is not what we want for long term, yet it is a temporary fix for release 0.17.

@TomDLT TomDLT added this to the 0.17 milestone Oct 7, 2015
@TomDLT TomDLT changed the title [WIP] temporary fix for sparse ridge with intercept fitting [MRG] temporary fix for sparse ridge with intercept fitting Oct 7, 2015
Comment thread sklearn/linear_model/ridge.py Outdated

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.

where do you check X is sparse?

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.

in the fit(), here

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.

and solver != "sag" right?

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.

Well, 'sag' currently uses the same centering trick than other solvers to avoid computing the intercept.
The intercept is computed with 'sag' only if the data has not been centered.

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.

Ok I got your point, I'll add it

@amueller

amueller commented Oct 9, 2015

Copy link
Copy Markdown
Member

needs a whatsnew, otherwise looks good apart from minor comments.

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.

or make_regression(...) + 10, right?

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.

Sure :) I was tired

@TomDLT
TomDLT force-pushed the sparseridge branch 2 times, most recently from 1768e44 to 19e4452 Compare October 9, 2015 17:40

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.

Could you please also add the case where solver != 'sag' and check for the solver switch warning with assert_warns?

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.

done

@ogrisel

ogrisel commented Oct 12, 2015

Copy link
Copy Markdown
Member

Apart from my last comment and a needed rebase on top of master, +1 for merge as well.

@ogrisel ogrisel changed the title [MRG] temporary fix for sparse ridge with intercept fitting [MRG+2] temporary fix for sparse ridge with intercept fitting Oct 12, 2015
@amueller

Copy link
Copy Markdown
Member

maybe @mblondel wants to do a quick look-over?

Comment thread sklearn/linear_model/ridge.py Outdated

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.

Doesn't this raise a warning even when the data isn't sparse?

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.

You are right, I did not think about the public use of ridge_regression.
I'll change that

@mblondel

Copy link
Copy Markdown
Member

LGTM once my comments are addressed.

In #4710, I gave another temporary quick fix which can be used with all solvers. It could be worth investing it if time permits.

@TomDLT

TomDLT commented Oct 13, 2015

Copy link
Copy Markdown
Member Author

In #4710, I gave another temporary quick fix which can be used with all solvers. It could be worth investing it if time permits.

I chose a quicker fix for the release of v0.17, but your suggestion might be better for long term.

TomDLT pushed a commit that referenced this pull request Oct 13, 2015
[MRG+2] temporary fix for sparse ridge with intercept fitting
@TomDLT
TomDLT merged commit 90922ea into scikit-learn:master Oct 13, 2015
@TomDLT
TomDLT deleted the sparseridge branch October 16, 2015 12:08
@giorgiop

Copy link
Copy Markdown
Contributor

I have noticed that the warning for sparse input is now in contrast with the dosctring.

@amueller

Copy link
Copy Markdown
Member

PR welcome @giorgiop ;)

@amueller

Copy link
Copy Markdown
Member

[or open an issue please?]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants