Added FunctionTransformer test and wrap refenrece#443
Added FunctionTransformer test and wrap refenrece#443nandevers wants to merge 4 commits intofeature-engine:mainfrom
Conversation
solegalli
left a comment
There was a problem hiding this comment.
Hi @nandevers
Thank you so much for your contribution!! This is looking really good.
I've got a minor comment on the tests, could you have a look?
Also, the code style test is failing, this is probably because there are some blank lines where they shouldn't or some code lines longer than they should be.
Fortunately, this can be corrected automatically with a python library called black, and tested with a python library called flake8.
More info here:
https://feature-engine.readthedocs.io/en/latest/contribute/contribute_code.html#test-code-style
Would you want to try those out?
When you run black, make sure to do it in your file only and in the test file (not in the entire project). And when you commit, make sure you commit only those files.
I look forward to those changes :)
thanks a lot!
PS: let me know if you need anything.
| assert output_feat == transformer.get_feature_names_out(varlist) | ||
|
|
||
|
|
||
| def test_sklearn_transformer_wrapper(): |
There was a problem hiding this comment.
I would rename this test for something with more information about what the aim of the test is.
In this particular case, we are wrapping the FunctionTransformer and we want to ensure that this transformer can work with categorical variables. So maybe rename to test_function_transformer_works_with_categoricals.
We could also add a test to test that it work with numericals (I am getting greedy, sorry, but let me make a code suggestion for the new test):
X = pd.DataFrame({
"col1": [1, 2, 3],
"col2": ["a", "b", "c"]
})
X_expected = pd.DataFrame({
"col1": [2, 3, 4],
"col2": ["a", "b", "c"]
})
transformer = SklearnTransformerWrapper(
FunctionTransformer(lambda x: x+1,
variables=["col1"]
)
you get the gist ;)
There was a problem hiding this comment.
Hi there, I have included these changes and tested the functions. Everything seems ok now, would you please let me now if there's anything else I can do to make it better?
There was a problem hiding this comment.
@solegalli, it turns out I accidentally included this file in formatting changes as well... do you reckon we could keep it and merge it together with the others or should I remove it from this PR?
tests/test_selection/test_check_estimator_selectors.py
Thanks a bunch
|
@solegalli I am closing this PR because it is a little messy right now. I'll open a new one in a bit |
Issue: #416
This PR modifies:
feature_engine/feature_engine/wrappers/wrappers.pyfeature_engine/tests/test_wrappers/test_sklearn_wrapper.pyPassed
pytest tests/test_wrappers/test_sklearn_wrapper.py -k 'test_sklearn_transformer_wrapper'test successfully :