-->

How to retrieve coefficient names after label enco

2019-02-27 13:32发布

问题:

I am running a machine learning model (Ridge Regression w/ Cross-Validation) using scikit-learn's RidgeCV() method. My data set has 5 categorical features and 2 numerical ones, so I started with LabelEncoder() to convert the categorical features to integers, and then I applied OneHotEncoder() to make several new feature columns of 0s and 1s, in order to apply my Machine Learning model.

My X_train is now a numpy array, and after fitting the model I am getting its coefficients, so I'm wondering -- is there a straightforward way to connect these coefficients back to the individual features they correspond to? Unlike Pandas get_dummies, OneHotEncoder doesn't seem to be generating any titles for the individual features it generates off of the labeled categorical ones...

PS: I have used LabelEncoder's .classes_ attribute and OneHotEncoder's .feature_indices_, but none of them gives me exactly what I'm looking for. I have inquired in Cross Validated but I was referred to Stack Overflow.