Is it possible to use sklearn Recursive Feature Elimination(RFE) with an estimator from another package?
Specifically, I want to use GLM from statsmodels package and wrap it in sklearn RFE?
If yes, could you please give some examples?
Is it possible to use sklearn Recursive Feature Elimination(RFE) with an estimator from another package?
Specifically, I want to use GLM from statsmodels package and wrap it in sklearn RFE?
If yes, could you please give some examples?
Yes, it is possible. You just need to create a class that inherit
sklearn.base.BaseEstimator
, make sure it hasfit
&predict
methods, and make sure itsfit
method expose feature importance through eithercoef_
orfeature_importances_
attribute. Here is a simplified example of a class: