[scikit-learn] function transformer
Sole Galli
solegalli at protonmail.com
Mon Jun 21 02:43:30 EDT 2021
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 <manpritsinghece at 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 ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20210621/d647068d/attachment.html>
More information about the scikit-learn
mailing list