import pandas as pd
from feature_engine.creation import RelativeFeatures
from sklearn.pipeline import make_pipeline
from sklearn.dummy import DummyClassifier
from sklearn import set_config
set_config(transform_output="pandas")
X = pd.DataFrame({"feature_1": [1, 2, 3, 4, 5], "feature_2": [6, 7, 8, 9, 10]})
y = pd.Series([0, 1, 0, 1, 0])
pipeline = make_pipeline(
RelativeFeatures(
variables=["feature_1"],
reference=["feature_2"],
func=["div"]
),
DummyClassifier()
)
pipeline.fit(X, y)
pipeline.predict(X)
ValueError: Length mismatch: Expected axis has 2 elements, new values have 3 elements
Describe the bug
Pipelines break when you use pandas transform output with feature creation.
To Reproduce
Steps to reproduce the behavior: