Skip to content

[MRG] BUG fix RidgeClassifierCV to accept custom score - #14848

Merged
agramfort merged 39 commits into
scikit-learn:masterfrom
venkyyuvy:scoring_clf_looe
Jan 6, 2020
Merged

[MRG] BUG fix RidgeClassifierCV to accept custom score#14848
agramfort merged 39 commits into
scikit-learn:masterfrom
venkyyuvy:scoring_clf_looe

Conversation

@venkyyuvy

@venkyyuvy venkyyuvy commented Aug 29, 2019

Copy link
Copy Markdown
Contributor

Fixes: #14672. Fixes #14856.

What does this implement/fix?

Added param is_clf to _BaseRidgeCV for identifying whether the problem is regression or classification.

Changes target variable transformation in .fit() based on input for cv because RidgeClassifierCV internally does the transformation.

I have included a test cases for both scenarios cv == None and cv!=None.

@venkyyuvy venkyyuvy changed the title Scoring clf looe [MRG] RidgeClassifierCV Scoring looe Aug 29, 2019
@venkyyuvy venkyyuvy changed the title [MRG] RidgeClassifierCV Scoring looe [MRG] RidgeClassifierCV Scoring loo Aug 31, 2019
@venkyyuvy

Copy link
Copy Markdown
Contributor Author

@amueller | @jnothman, help required.

My latest commit is failing in codecov/patch but I am not able to understand where I am making a mistake. In fact, I had already included a new test case for my code.

Expecting some guidance here.

Comment thread sklearn/linear_model/ridge.py Outdated
Comment thread sklearn/linear_model/ridge.py Outdated
Comment thread sklearn/linear_model/ridge.py Outdated
@venkyyuvy

venkyyuvy commented Sep 25, 2019

Copy link
Copy Markdown
Contributor Author

ping @amueller

If time permits, please share your reviews

@agramfort

Copy link
Copy Markdown
Member

@venkyyuvy please address @glemaitre reviews before asking for more.

@venkyyuvy

venkyyuvy commented Sep 30, 2019

Copy link
Copy Markdown
Contributor Author

Sorry for that. I thought that I had addressed the reviews from @glemaitre. Please let me know, if I had misunderstood.

@venkyyuvy venkyyuvy closed this Sep 30, 2019
@venkyyuvy venkyyuvy reopened this Sep 30, 2019
@venkyyuvy

venkyyuvy commented Oct 8, 2019

Copy link
Copy Markdown
Contributor Author

Hi @agramfort,

There is no additional response from @glemaitre,
Can I request for another review now?

@jeromedockes

Copy link
Copy Markdown
Contributor

the error persists when cv != None

@venkyyuvy

Copy link
Copy Markdown
Contributor Author

the error persists when cv != None

True. I had raised another issue for this and am waiting for members to give me a thumbs up to start working on that.

@venkyyuvy

Copy link
Copy Markdown
Contributor Author

@NicolasHug,

Could please review this PR?

@glemaitre

Copy link
Copy Markdown
Member

@venkyyuvy I made a PR there: venkyyuvy#3
such that it will be ok with the refactoring done in #15652

@venkyyuvy

Copy link
Copy Markdown
Contributor Author

@venkyyuvy I made a PR there: venkyyuvy#3
such that it will be ok with the refactoring done in #15652

Thanks a lot @glemaitre.
I haven't been notified of your PR before, that is the reason why I had pinged here.
Looking forward for your review now.

@glemaitre glemaitre 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.

@qinhanmin2014 could you have a look at it. This PR is only here to check that we can pass a scoring to RidgeClassificationCV. We are getting closer to what we want to do :)

Comment thread doc/whats_new/v0.23.rst Outdated
@glemaitre

glemaitre commented Dec 10, 2019 via email

Copy link
Copy Markdown
Member

Comment thread sklearn/linear_model/_ridge.py
@glemaitre glemaitre changed the title [MRG] RidgeClassifierCV Scoring loo [MRG] BUG fix RidgeClassifierCV to accept custom score Dec 23, 2019
@glemaitre

Copy link
Copy Markdown
Member

ping @amueller (maybe :))

Comment thread sklearn/linear_model/tests/test_ridge.py Outdated
Comment thread sklearn/linear_model/tests/test_ridge.py Outdated
Comment thread sklearn/linear_model/tests/test_ridge.py Outdated

@pytest.mark.parametrize("scoring", [None, "accuracy", _accuracy_callable])
@pytest.mark.parametrize("cv", [None, KFold(5)])
@pytest.mark.parametrize("filter_", [DENSE_FILTER, SPARSE_FILTER])

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.

I would test also with a dummy callable that return let's say 0.42 all the time and check that the score I obtain is actually 0.42 and that the C selected is the smallest one (strongest regularization). In case of tie between cv_scores you should always pick the most regularized model.

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.

so larger alpha then

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.

Actually, tests are failing. We pick up the smallest alpha instead of the largest one.

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.

The reason is that we loop over the alphas in the order in the constructor.
Therefore, it will keep alphas[0] in all cases. If we want to apply your suggestion we need to change the behaviour of RidgeCV and RidgeClassifierCV

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.

We can address this in another PR then.

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.

+1 to do it in another PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can I work this PR?

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.

I already open one there: #16029
But feel free to comment and contribute. I think that I found some other bugs.

Comment thread sklearn/linear_model/tests/test_ridge.py Outdated
@glemaitre glemaitre self-assigned this Jan 6, 2020
@glemaitre

Copy link
Copy Markdown
Member

@agramfort you can probably merge then :)

@agramfort

Copy link
Copy Markdown
Member

thx @venkyyuvy and @glemaitre !

panpiort8 pushed a commit to panpiort8/scikit-learn that referenced this pull request Mar 3, 2020
…14848)

* handle_clf_ridgeGCV

* included test case

* undo_lambda_rm

* crtd_commet

* check_y

* include_comp_proba

* fix_format

* added more comment for is_clf condtn

* adding param is_clf

* adding super

* format fixes

* init params

* moving param 2 inint

* using is_classifier

* removing super

* ENH do not allocate local arrays in Ridge*CV of store_cv_vales is False

* add whats new

* TST check multiple metrics for RidgeCV

* linting

* update whats new

* missing doc when solving conflict

* missing doc

* style

* correct whats new

* fix

* address agramfort comments

* fix

Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
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.

RidgeClassifierCV is not working when scoring params is fed RidgeClassifierCV bug when using scoring

8 participants