Repository navigation
FIX LogisticRegressionCV with CV split with missing class labels - #32747
Conversation
|
CD fc3e82e fails as expected in |
|
@lesteve fyi, up to you to include it either in 1.8.0 or 1.8.1. |
| else: | ||
| score_params = score_params or {} | ||
| score_params = _check_method_params(X=X, params=score_params, indices=test) | ||
| # FIXME: If scoring = "neg_brier_score" and if not all class labels |
There was a problem hiding this comment.
For a custom scorers, I think the caller is responsible for creating a scorer with labels set, but it's not obvious.
Not for this PR: I have not looked closely, but we can inspect the scoring object to see if it contains a metric that supports labels and pass it in. Although this idea feels like a hack.
|
Thanks for the PR @lorentzenchr! I clicked on "Update branch" because it looks like the CI was in a weird state. The fix looks fine at a glance, I'll take a closer look at this today, push a few tweaks and merge it. |
| coefs = clf_multi.coefs_paths_[fold, 0, :, :, :-1] | ||
| coefs = coefs.reshape(len(clf_multi.Cs_), -1) | ||
| norms = np.sum(coefs * coefs, axis=1) # L2 norm for each C | ||
| norms = np.sum(coefs * coefs, axis=(-2, -1)) # L2 norm for each C |
There was a problem hiding this comment.
Note to our future selves, this is a left-over from #32073 (review). I merged #32073 too soon and forgot about it ...
|
If CD still green, ready from my site. |
|
Preferably: first merge #32659 then this one. |
|
I am going to merge this one first, since I feel it is ready. The conflicts are going to be painful to solve whichever we merged first I think ... |
Reference Issues/PRs
Fix #32748 and #30832
Leftover from #32073 (comment).
What does this implement/fix? Explain your changes.
If a CV fold in
LogisticRegressionCVhas not all classes present, the result is more or less random (certain solvers emit convergence warnings). This PR adds a test (CI will first fail) and then fix the test.Any other comments?