def select_feature(train, targets, test, thresh): model = XGBClassifier() model.fit(train, targets) model = SelectFromModel(model, threshold=thresh, prefit=True) train_reduced = model.transform(train) test_reduced = model.transform(test) return train_reduced, test_reduced