Repository navigation
FIX Fix TargetEncoder error with metadata routing enabled and without groups - #35185
Conversation
|
Thank you for opening your first pull request to scikit-learn! 🎉 To help get your contribution reviewed, please make sure that:
|
|
Thanks a lot for the PR, cc @StefanieSenger for visibility. |
|
Side-question for @lepennec, I am curious about how people use metadata routing in the wild and what kind of use cases they have. Can you explain in a few words what you use metadata routing for in your course? Maybe you have some public course materials that I can look at 🙏? |
lesteve
left a comment
There was a problem hiding this comment.
Looks good to me, thanks for the issue and PR!
I pushed a small tweak to make the test function name more explicit and add a reference to the original issue.
I have a few labs in which I use an X-aware cost, i.e., a cost in which the loss depends on Y and f(X) as usual, but also on X itself. For instance, if you want to accept or not a loan, the amount of the loan is important. To use such a custom cost/metric in the scikit-learn cross-validation machinery, you need to route this amount. I have sent you an invitation to a WIP repository in which I use this. The first example is exercise 2 of Lab 1. |
Thanks for sharing this. That's pretty much like @glemaitre's Post-tuning the decision threshold for cost-sensitive learning. Do you also use TunedThreshold* for this? |
StefanieSenger
left a comment
There was a problem hiding this comment.
This looks great. Thanks a lot for the report and the fix, @lepennec.
And congratulations to you first scikit-learn contribution.🥇
This is indeed very similar and could probably be traced back to the same source (we worked together on a continuous education program). I stick to the optimal Bayes predictor and thus do not further optimize the threshold; that is, however, a good idea of follow-up. |
|
Just passing by to say hello @lepennec :) Nice to see that use cases where the work of the past releases has an impact. They are certainly advanced cases but real one. |
Reference Issues/PRs
Fixes #35139
What does this implement/fix? Explain your changes.
With enable_metadata_routing=True, TargetEncoder.fit_transform(X, y) raises KeyError: 'groups' when it is called without groups.
This PR solves the issue with a one-line modification in ".../sklearn/preprocessing/_target_encoder.py", line 366.
by
Introduce yourself
I am a professor of applied math at École polytechnique, very close to the Turing build, so important to the scikit-learn community. I use scikit-learn mainly for teaching, as the ones doing the hard jobs are now my students. I am the original poster of the issue.
AI usage disclosure
I used AI assistance for: