Skip to content

[MRG+2] Adding Implementation of SAG - next episode#4738

Closed
TomDLT wants to merge 11 commits intoscikit-learn:masterfrom
TomDLT:sag
Closed

[MRG+2] Adding Implementation of SAG - next episode#4738
TomDLT wants to merge 11 commits intoscikit-learn:masterfrom
TomDLT:sag

Conversation

@TomDLT
Copy link
Copy Markdown
Member

@TomDLT TomDLT commented May 19, 2015

I took over the great work of @dsullivan7 in #3814.

I removed the merges with master, squashed all the commits and rebased on master.

@dsullivan7
Copy link
Copy Markdown
Contributor

Awesome @TomDLT! There was talk of having this implemented as a solver for LogisticRegression and RidgeRegression, have you looked into that at all?

@amueller
Copy link
Copy Markdown
Member

travis is still unhappy ;) Thanks for picking this up!

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented May 19, 2015

I rerun the classifier benchmark on two large datasets:
RCV1 and Alpha (cf here)
The plot shows the convergence with log10(|loss - loss_optimal|)

Result on Alpha (500.000 x 500, Dense):
diffloss
Result on RCV1 (804.414 x 47.152, Sparse):
diffloss

@agramfort
Copy link
Copy Markdown
Member

as discussed I vote for adding 'sag' solver to LogisticRegression and RidgeRegression that would call plain sag_logistic and sag_ridge functions.

@amueller
Copy link
Copy Markdown
Member

newtoncg is faster than liblinear? I'm surprised! Anyhow SAG seems to kick ass. I'd be +1 on adding a solver to the classifiers as this seems like a good default.

@amueller
Copy link
Copy Markdown
Member

(though i dream of the day where the default LogisticRegression is multinomial, not OvR ;)

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented May 19, 2015

newton-cg is faster than liblinear? I'm surprised!

Actually, newton-cg is not faster.
In previous example, with fit_intercept=True, liblinear and newton-cg does not converge to the same minimum, since liblinear use a regularization on the intercept, whereas newton-cg and SAG don't.

I tried using the same regularization in SAG, and it converges to the same minimum as liblinear.
However, it makes more sense not to regularize the intercept.

Finally, with fit_intercept=False, we see that liblinear is a not slower than newton-cg.
diffloss_no_intercept

@amueller
Copy link
Copy Markdown
Member

Thanks for the explanation.

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented May 20, 2015

I implemented sag_logistic as a solver in LogisticRegression, and changed accordingly some of the tests.

Currently, in order to match LogisticRegression API, and compared to previous SAGClassifier,

  • eta is forced to 'auto'
  • we loose the warm_start
  • we loose parallel processing for multiclass
  • the behavior with multiclass with class weights is changed (it is now the same as in other LogisticRegression solvers with 'OvR' strategy)

@amueller
Copy link
Copy Markdown
Member

why do we lose warm_start?

@agramfort
Copy link
Copy Markdown
Member

there is no reason not to support warm_start

I would put all sag related code in 1 file called sag.py (ie no sag_class.py)

@agramfort
Copy link
Copy Markdown
Member

travis is not happy

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented May 21, 2015

For warm_start, how should I pass the option without adding parameters to LogisticRegression?

@agramfort
Copy link
Copy Markdown
Member

agramfort commented May 21, 2015 via email

@TomDLT TomDLT force-pushed the sag branch 2 times, most recently from 38af560 to 2e9618b Compare May 21, 2015 09:06
@agramfort
Copy link
Copy Markdown
Member

ping us when ready to merge.

thx

@amueller
Copy link
Copy Markdown
Member

I also thought there was a warm_start for LogisticRegressionCV... hum

@amueller
Copy link
Copy Markdown
Member

needs a rebase (probably for whatsnew)

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented May 21, 2015

I implemented sag_ridge as a solver in Ridge, and changed accordingly some of the tests.

Currently, in order to match Ridge API, and compared to previous SAGRegressor,

  • eta is forced to 'auto'
  • we loose random_state and warm_start

@TomDLT TomDLT force-pushed the sag branch 4 times, most recently from b37cfcc to a1adf82 Compare May 21, 2015 16:35
@agramfort
Copy link
Copy Markdown
Member

agramfort commented May 21, 2015 via email

@amueller
Copy link
Copy Markdown
Member

yeah

@amueller
Copy link
Copy Markdown
Member

shouldn't LogisticRegression have a random_state for liblinear? Or is that only for hinge-loss?

@agramfort
Copy link
Copy Markdown
Member

agramfort commented May 21, 2015 via email

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented May 21, 2015

No, LogisticRegression class has a random_state, and so has sag_logistic.
It is missing in Ridge class, so it is currently missing also in sag_ridge.

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented Sep 9, 2015

Thanks again for the review!

FYI I am working on a multinomial version of SAG, but it will be in another PR.

@agramfort
Copy link
Copy Markdown
Member

agramfort commented Sep 9, 2015 via email

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.

space before "By" ;)

@amueller
Copy link
Copy Markdown
Member

amueller commented Sep 9, 2015

@ogrisel we want this in the release, right?

@amueller
Copy link
Copy Markdown
Member

amueller commented Sep 9, 2015

Great work everybody :)

@amueller amueller added this to the 0.17 milestone Sep 9, 2015
@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Sep 9, 2015

@ogrisel we want this in the release, right?

I am not opposed to have it in :)

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Sep 10, 2015

FYI I am working on a multinomial version of SAG, but it will be in another PR.

Would be great to consider adding support for sample_weight to LogisticRegression and LogisticRegressionCV as well while you are at it.

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Sep 10, 2015

This PR needs a rebase on top of the current master.

@amueller
Copy link
Copy Markdown
Member

I'll rebase, squash and merge in a bit unless anyone complains.

@amueller
Copy link
Copy Markdown
Member

Pushed as 94eb619. Thanks for the great work!

@agramfort
Copy link
Copy Markdown
Member

agramfort commented Sep 10, 2015 via email

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Sep 11, 2015

🍻!

@dsullivan7
Copy link
Copy Markdown
Contributor

Awesome!!

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented Sep 11, 2015

Nice !

@fabianp
Copy link
Copy Markdown
Member

fabianp commented Sep 11, 2015

Yeah! @TomDLT deserves extra kudos for patience and perseverance :-)

@TomDLT
Copy link
Copy Markdown
Member Author

TomDLT commented Sep 11, 2015

Thanks :)

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.

10 participants