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
Bugfix for #158 #159
Bugfix for #158 #159
Conversation
|
|
ah yes. those are tricky. i see two paths going forward and maybe a check with @MBrouns might be good.
The sklearn tests are guidelines that are easy to automate but they aren't devine gospel. @pim-hoeven feel free to question my thoughts here if you have a better alternative. |
I think the second approach makes more sense for two reasons:
Regarding the So, (@MBrouns) my proposed solution would be:
Do you agree? |
Sounds great to me. |
…ikit-lego into 158-string-values-as-group
sklego/meta.py
Outdated
def __validate(self, X, y=None): | ||
try: | ||
X_data = X.drop(columns=self.groups, inplace=False) | ||
except AttributeError: # np.array |
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.
it feels cleaner to test this using isinstance(X, pd.DataFrame)
would you not agree?
sklego/meta.py
Outdated
@@ -54,6 +54,47 @@ def __init__(self, estimator, groups, use_fallback=True): | |||
self.groups = groups | |||
self.use_fallback = use_fallback | |||
|
|||
def __check_group_cols_exist(self, X): | |||
try: |
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.
checking the type of X
is probably better to do via isinstance
instead waiting for an AttributeError
.
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 agree that in this case the intent is clearer with an isinstance check.
|
|
…ikit-lego into 158-string-values-as-group
sklego/meta.py
Outdated
@@ -54,6 +54,47 @@ def __init__(self, estimator, groups, use_fallback=True): | |||
self.groups = groups | |||
self.use_fallback = use_fallback | |||
|
|||
def __check_group_cols_exist(self, X): | |||
try: |
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 agree that in this case the intent is clearer with an isinstance check.
sklego/meta.py
Outdated
except AttributeError: | ||
try: | ||
ncols = X.shape[1] | ||
except IndexError: |
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.
is X
ever only 1d?
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 guess it could be. groupby-mean as a model?
Apologies for the delay, I made the requested changes |
No worries about the delay, it is all volunteer work. |
There is something interesting happening in the ci pipeline though. It runs fine locally?
|
No I didn't have these locally, but only ran the relevant tests. Is the pandas issue something I can / should change? |
i haven't looked at your code yet but i'll prolly make a fix tomorrow/day after. once that is merged to master we can try again. :) |
@pim-hoeven do check the conversations. it feels like a comment here and there might still be missing. |
I am fixing the failing tests here; #167 |
Also, just to check @pim-hoeven, you've got a sticker right? |
|
Fixed the bug caused when using the grouped_estimator with a string column as grouping variable.
Solution: Try the checks without adjustments, if that fails: remove the grouping column from the array or dataframe.