1
$\begingroup$

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(
    boosting_type='gbdt',
    objective='binary',
    learning_rate=0.01,
    colsample_bytree=0.9,
    subsample=0.8,
    random_state=21,
    n_estimators=200,
    num_leaves=18)
sel = RFE(gbm, step=1, n_features_to_select=20, verbose=1)
sel.fit(X_train, y_train)
print (sel.ranking_)
$\endgroup$
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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