<div dir="ltr"><div> Dear Sir, <br></div><div>I  have made such a transformer, below given is an example that generates 3 new columns, from existing 2 columns of a numpy array , first column is for element wise addition, second is for element wise multiplication and third is for element wise  division .</div><div><br></div><div>>>> import numpy as np<br>>>> from sklearn.preprocessing import FunctionTransformer<br>>>> def col_add(x):<br>           x1 = x[:, 0] + x[:, 1]<br>           x2 = x[:, 0] * x[:, 1]<br>           x3 = x[:, 0] / x[:, 1]<br>           return np.c_[x, x1, x2, x3]<br><br>>>> col_adder = FunctionTransformer(col_add)<br>>>> arr = np.array([[2, 7], [4, 9], [3, 5]])<br>>>> arr<br>array([[2, 7],<br>       [4, 9],<br>       [3, 5]])<br>>>> col_adder.transform(arr) # will add 3 columns<br>array([[ 2.        ,  7.        ,  9.        , 14.        ,  0.28571429],<br>       [ 4.        ,  9.        , 13.        , 36.        ,  0.44444444],<br>       [ 3.        ,  5.        ,  8.        , 15.        ,  0.6       ]])<br>>>> <br></div><div><br></div><div>So in this way a function transformer can be used to add new features generated from existing columns ?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 18, 2021 at 4:15 PM Manprit Singh <<a href="mailto:manpritsinghece@gmail.com" target="_blank">manpritsinghece@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear sir , <br></div><div><br></div><div>Just need to know if I can use a function transformer to generate new columns in the data set . <br></div><div><br></div><div>Just see the below written pipeline </div><div><br></div><div>num_pipeline = Pipeline([('imputer', SimpleImputer(strategy="median")),<br>                         ('attribs_adder', column_adder),<br>                         ('std_scaler', StandardScaler()),<br>                        ])</div><div>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 . <br></div><div><br></div><div>The columns being added 
are generated from existing columns (by element wise division of two 
columns) . So Using a function transformer is ok ?</div></div>
</blockquote></div>