Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformer Pipeline output #15

Open
luistelmocosta opened this issue Oct 21, 2022 · 0 comments
Open

Transformer Pipeline output #15

luistelmocosta opened this issue Oct 21, 2022 · 0 comments

Comments

@luistelmocosta
Copy link

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant