The FunctionTransformer will apply the transformation coded your function to
the entire dataset passed to the transform() method.
I find it hard to see how this could work to add additional columns to the
dataset, but I guess it might depend on how you designed your function.
Did you try passing your function to the FunctionTransformer and then apply the
transform() method on your data and see the result?
Alternatively, you could create your own class to add additional columns to
your data and pass that class within the pipeline.
Or, easier, use the
[CombineWithFeatureReference](https://feature-engine.readthedocs.io/en/latest/creation/CombineWithReferenceFeature.html)
transformer from another open source package for feature engineering
(Feature-engine), which does exactly what you want to do.
Hope this helps
Soledad Galli
https://www.trainindata.com/
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, June 18th, 2021 at 12:45 PM, Manprit Singh
<manpritsingh...@gmail.com> wrote:
> Dear sir ,
>
> Just need to know if I can use a function transformer to generate new columns
> in the data set .
>
> Just see the below written pipeline
>
> num_pipeline = Pipeline([('imputer', SimpleImputer(strategy="median")),
> ('attribs_adder', column_adder),
> ('std_scaler', StandardScaler()),
> ])
> This pipeline is for numerical attributes in the dataset, firstly it will
> treat all mising values in the data set using SimpleImputer , then i have
> made a function to add three more columns in the existing data, i have made a
> function transformer with this function and then StandardScaler .
>
> The columns being added are generated from existing columns (by element wise
> division of two columns) . So Using a function transformer is ok ?
_______________________________________________
scikit-learn mailing list
scikit-learn@python.org
https://mail.python.org/mailman/listinfo/scikit-learn