Skip to content

Transformer Pipeline output  #15

Description

@luistelmocosta

Hello!
I was following your transformation step implementation and I am having some issues with the output. Applying the encoders as the second step of the pipeline makes it return the features that are affected by the scaler. In your case it would be ["trip_distance", "trip_duration"].

def transformer_fn():
    """
    Returns an *unfitted* transformer that defines ``fit()`` and ``transform()`` methods.
    The transformer's input and output signatures should be compatible with scikit-learn
    transformers.
    """
    

    function_transformer_params = (
        {}
        if sklearn.__version__.startswith("1.0")
        else {"feature_names_out": "one-to-one"}
    )
    
    return Pipeline(
        steps=[
           (
                "calculate_features",
                FunctionTransformer(calculate_features, **function_transformer_params),
            ),
          (
                "encoder",
                ColumnTransformer(
                    transformers=[
                        (
                            "robust_scaler",
                            RobustScaler(),
                            ["competition_distance", "competition_time_month"],
                        ),
                        (
                            "min_max_scaler",
                            MinMaxScaler(),
                            ["promo_time_week"],
                        )
                    ]
                ),
            ),
          
        ]
    )

This is my transformer_fn and this is what I am getting:

image

How do you combine the transformed features with the dataset pre-transformed? What am I missing?

Thank you :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions