How to retrieve coefficient names after label encoding and one hot encoding on scikit-learn?

旧时模样 提交于 2019-12-31 03:29:05

问题


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.

来源:https://stackoverflow.com/questions/40141710/how-to-retrieve-coefficient-names-after-label-encoding-and-one-hot-encoding-on-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!