question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CalibratedClassifierCV doesn't support groups parameter in fit method

See original GitHub issue

Description

With classes like sklearn.model_selection.GridSearchCV and even skopt.BayesSearchCV they take a cv parameter that can be any object that produces train/test splits. In the case of using sklearn.model_selection.GroupKFold as the cv object, it requires a groups variable to be passed to fit. In both these classes, they allow groups to be passed to fit that’s then passed to the underlying GroupKFold. However, sklearn.calibration.CalibratedClassifierCV doesn’t allow the groups variable to fit even though it says it accepts any cv object.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
adrinjalalicommented, Sep 11, 2018

This is I guess another example of what could potentially be solved by PR #9566. You can check issues #11429 and #4497 for more detailed discussion on the matter. Developers are mostly busy with 0.20 release at the moment. I’m pretty sure we’ll get back to this soon after the release.

In the meantime, you can check the answer I gave to the question “sklearn GridSearchCV not using sample_weight in score function” on stackoverflow useful. I haven’t applied it to GroupKFold, but I suspect it may be applicable there as well. You may need to write a wrapper around GroupKFold which doesn’t expect groups as input.

0reactions
mdbeckercommented, Nov 5, 2021

For anyone else that runs into this same issue before SLEP006 is finished, I’ve uploaded a very simple fix based on version 0.24.1 of sklearn here. This works the same was a GridSearchCV and fails gracefully if the cv passed in does not support the groups parameter (which may not be desirable depending on your usecase). @DanLeopold

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use GroupKFold with CalibratedClassifierCV?
Unlike GridSearchCV , CalibratedClassifierCV doesn't seem to support passing the groups parameter to the fit method.
Read more >
sklearn.calibration.CalibratedClassifierCV
Parameters to pass to the fit method of the underlying classifier. Returns: selfobject. Returns an instance of self.
Read more >
Re: Probability calibration in Dataiku
CalibratedClassifierCV from the classifier trained in Dataiku. My understanding is that the only way to do this is by creating a custom Python ......
Read more >
How to Calibrate Probabilities for Imbalanced Classification
Cross-validation is used to scale the predicted probabilities from the model, set via the “cv” argument. This means that the model is fit...
Read more >
Scikit correct way to calibrate classifiers with ... - Cross Validated
Which has the disadvantage of leaving less data for training. Also, if CalibratedClassifierCV should only be fit on models fit on a different ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found