I used the the feature selection method: RFE to select feature for features. Now I want to select 20 features(there are about 50 features or more) with LGBM model as following code: But I found that the features(sel.ranking_) are different when the os or os version, or computer is changed. I don't know what caused the changing. More, how to solve it that features selection is fixed. Thanks!

gbm = lgb.LGBMClassifier(
sel = RFE(gbm, step=1, n_features_to_select=20, verbose=1)
sel.fit(X_train, y_train)
print (sel.ranking_)

1 Answer 1


Since you do not provide any information about the creation of X_train and y_train I cannot be sure that this is the issue, but I would guess that it has to do with some change in the order of the features. Three-based algorithms' results are affected when the order of the input features changes, so make sure that this order does not change every time you run your code (e.g. you can sort them alphabetically before RFE).

You might find this discussion interesting.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.