Repository navigation
FIX: Fixed duplicate column error appearing with FeatureUnion polars - #32853
Conversation
ogrisel
left a comment
There was a problem hiding this comment.
Thanks for the fix. It looks correct to me but I think the testing of pandas and polars should be decoupled:
… ensure the whole test is not skipped if only one of the dependencies is installed
ogrisel
left a comment
There was a problem hiding this comment.
Sorry for the late feedback. LGTM!
|
I synced this PR with |
There was a problem hiding this comment.
This looks good to me.
One small comment: for bug reports like #32852 that come with a good and short reproducer we sometimes include an explicit test with the reproducer and a comment saying "non regression test for gh-32852". I think we test the relevant functionality already in test_feature_union_set_output (the reason it didn't catch the bug is because we didn't test with polars), but maybe it makes sense to add that non regression test
When I checkout this PR locally and run the following snippet everything works:
from sklearn.pipeline import FeatureUnion
from sklearn.preprocessing import StandardScaler
from sklearn import set_config
import numpy as np
set_config(transform_output="polars")
X = np.array([[1, 2], [3, 4], [5, 6]])
union = FeatureUnion([
("scaler1", StandardScaler()),
("scaler2", StandardScaler())
])
result = union.fit_transform(X)
I don't think we need an extra non regression test since the existing test updated in this PR covers the polars case now. I would rather avoid redundant tests. |
A non-regression test would have been useful here 😄 Also, this PR did not completely fix the issue and introduced a regression at the same time because it did not take transformers that don't implement The fixed that I proposed before this PR in #32106 is a more robust fix and removes the newly introduced regression. @betatim since you reviewed this one, maybe you can have a look ? |
PR: scikit-learn#32853 Issue: scikit-learn#32852 Base commit: e2d2cde Changed lines: 38
When using FeatureUnion with set_config(transform_output="polars"), the operation failed with polars.exceptions.DuplicateError because the ContainerAdapterProtocol.hstack() interface was incomplete: it didn't accept a
feature_namesparameter to apply column renaming before concatenation.Fixes #32852