简体   繁体   中英

How to know the order and labels of columns where the feature engineering is done?

I have been given a assignment by my teacher for doing practise on Basic Feature engineering taught in class. So I did practise it on a basic dataset which looks as follows:- 在此处输入图像描述

pipe_age=Pipeline([("infused",SimpleImputer(strategy='median')),
                  ("scaled",StandardScaler())])
pipe_No_of_Children=Pipeline([("scaled_child",StandardScaler())])
pipe_balance=Pipeline([("infused_bala",SimpleImputer(strategy='mean')),
                  ("scaled_bala",StandardScaler())])
pipe_city=Pipeline([("one_hot_encod",OneHotEncoder(sparse=False)),
                  ("scaled_city",StandardScaler())])
pipe_ratings=Pipeline([("ordinal_encod",OrdinalEncoder(categories=[["Excellent",'Good', 'Bad','Can Improve']])),
                  ("scaled_ratings",StandardScaler())])
pipe_fico_min=Pipeline([("scaled_fico_min",StandardScaler())])
pipe_fico_max=Pipeline([("scaled_fico_max",StandardScaler())])


pre_processing=ColumnTransformer(transformers=[("pipe_age",pipe_age,["Age"]),
                                              ("pipe_city",pipe_city,["CITY"]),
                                              ("pipe_rating",pipe_ratings,["Ratings"]),
                                              ("pipe_balance",pipe_balance,["Balances"]),
                                              ("pipe_children",pipe_No_of_Children,["No_of_Children"]),
                                              ("pipe_fico_min",pipe_fico_min,["fico_min"]),
                                              ("pipe_fico_max",pipe_fico_max,["fico_max"])])

pre_processing.fit(df)

pd.DataFrame(pre_processing.transform(df))

在此处输入图像描述

Now after doing above I could not understand which columns refer to columns present in actual data frame. How to give labels to columns during the above transformation so that after that's done it's easy to distinguish the columns?

Like here 0,1,2 represents which columns in main data set

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM