Feature names from OneHotEncoder

后端 未结 3 1139
我寻月下人不归
我寻月下人不归 2021-02-05 03:46

I am using OneHotEncoder to encode few categorical variables (eg - Sex and AgeGroup). The resulting feature names from the encoder are like - \'x0_female\', \'x0_male\', \'x1_0.

3条回答
  •  你的背包
    2021-02-05 04:21

    column_name = encoder.get_feature_names(['Sex', 'AgeGroup'])
    one_hot_encoded_frame =  pd.DataFrame(train_X_encoded, columns= column_name)
    

提交回复
热议问题