-
Notifications
You must be signed in to change notification settings - Fork 118
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
Introducing FormulaicTransformer
and deprecating PatsyTransformer
#593
Conversation
@deprecated( | ||
version="0.6.17", | ||
reason="Please use `sklego.preprocessing.FormulaicTransformer` instead. " | ||
"This object will be removed from the preprocessing submodule in version 0.9.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.
Totally made up version number in which to remove😂
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.
No worries :) That said ... I'd be fine with 0.8.0.
assert pipe.fit(X, y).predict(X).shape[0] == X.shape[0] | ||
|
||
|
||
def test_unseen_categories(df): |
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.
Differently from patsy, formulaic raises a warning but doesn't break with unseen categories
FormulaicTransformer
and deprecating PatsyTransformer
assert isinstance(df_fit_transformed, expected_type) | ||
|
||
|
||
|
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.
One extra test for this one, could we confirm that we're able to save/load this component? This was an issue with patsy because it wouldn't pickle.
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.
Just added pickling test.
Also found in the formulaic changelogs that from 0.3.0:
Pickleability is now guaranteed and tested via unit tests. Failure to pickle any formulaic metadata object (such as formulas, model specs, etc) is considered a bug.
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've only been able to glance it but it looks good! It'd be nice to add one extra test though, just to be sure.
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.
This is pretty neat :) thanks!
Description
Addresses #559 by deprecating
PatsyTransformer
and introducing aFormulaicTransformer
.In writing of
FormulaicTranformer
I followed what is described in the formulaic documentation for integrating with sklearn. The main (tiny) differences with such implementation can be summarized as:return_type
parameter available (similar to whatPatsyTransformer
does)__init__
method.transform()
Additionally the PR makes both dependencies optional.
Type of change
Checklist: