-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hierarchical predictors #623
Conversation
@@ -0,0 +1,33 @@ | |||
# Shrinkage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deserve their own page, at least in API
@@ -177,6 +177,50 @@ This transformer also has use-cases beyond fairness. You could use this transfor | |||
|
|||
For example, for predicting house prices, using the surface of a house relatively to houses in the same neighborhood could be a more relevant feature than the surface relative to all houses. | |||
|
|||
## Hierarchical Prediction | |||
|
|||
!!! info "New in version 0.8.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, totally made up version number. Need to be fixed accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with 0.8.0. Just gotta get this reviewed.
def equal_shrinkage(group_sizes) -> np.ndarray: | ||
"""Each group is weighed equally. | ||
|
||
Parameters | ||
---------- | ||
group_sizes : array-like | ||
The number of observations in each group, must implement the `__len__` method. | ||
|
||
Returns | ||
------- | ||
np.ndarray | ||
The weights for each group. | ||
""" | ||
return np.ones(len(group_sizes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want this to exist, but it felt like an easy one to add
Forgot to mention a couple of ideas:
|
At the moment I'd be fine with this:
But it would be preferable to have this documented in the code with comments. I agree that it's merely "ok", but it feels clear enough if the comment is there, no? |
Ah yeah, that's even nicer. Just in the comments would've been sufficient but adding it in the docs for sure is a nice touch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main observation is that we might want to add an extra test that uses a dummy model to help predict the values that we'd expect. Other than that; this looks great! Good work :)
I am thinking out loud here but...maybe the easiest way to check this is to use a deterministic/fake predictions model. Does that sound reasonable? |
Oh that was totally in line with what I had in mind. I've used Dummy models for this in the past but you're also free to pick another method. As long as we just have a test that our assumptions on how we shrink play out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
HierarchicalPredictor
,HierarchicalClassifier
andHierarchicalRegressor
- Partially fixesHierarchicalPredictor
andHierarchicalTransformer
#620ShrinkageMixin
to abstract such shared functionalities fromHierarchicalPredictor
andGroupedPredictor
equal_shrinkage
Type of change
Checklist: