Skip to content

Huge model growth with tree-based feature selection #27488

Closed Answered by jondo
jondo asked this question in Q&A
Discussion options

You must be logged in to vote

Replacing with a ColumnTransformer worked!
This is how I kept the selected features:

selected_features = pipeline[1].get_feature_names_out(X_fit.columns)
column_transformer = ColumnTransformer(transformers=[('keep', 'passthrough', selected_features)])
column_transformer.fit(X_fit, y_fit)
pipeline.steps[1] =  ('dimension_reduction', column_transformer)

For this, the first step needed to be configured as MinMaxScaler().set_output(transform="pandas").

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jondo
Comment options

@jondo
Comment options

@jondo
Comment options

Answer selected by jondo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants