Skip to content

Pipelines using pandas transform output do not work with feature creation #670

Description

@admivsn

Describe the bug
Pipelines break when you use pandas transform output with feature creation.

To Reproduce
Steps to reproduce the behavior:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions