Skip to content

Migrate the selection base classes and helpers to narwhals, add polars support - #1070

Open
solegalli wants to merge 3 commits into
narwhals-migrationfrom
narwhals-selection-base
Open

solegalli wants to merge 3 commits into
narwhals-migrationfrom
narwhals-selection-base

Conversation

@solegalli

@solegalli solegalli commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

The selection base classes and shared functions use check_X and the dataframe helpers, and no longer import pandas. The selectors themselves are migrated in their own PRs. Correlations are computed with numpy, which makes find_correlated_features much faster on pandas, for example 8 s to 34 ms with 1,000 variables.

Output is unchanged on pandas, and polars gives the same values. For polars, feature_importances_ and feature_importances_std_ are dictionaries keyed by feature, since there is no pandas Series; pandas users still get a Series.

solegalli and others added 3 commits November 21, 2026 11:05
…s support

BaseSelector.transform() returns the retained features in the train set
order, in the same library as the input (pandas X[features], narwhals
select otherwise). BaseRecursiveSelector.fit() trains the estimators on
native frames and returns (nw_X, y). The helpers in
base_selection_functions no longer import pandas: correlations are
computed with numpy (np.corrcoef, or matrix products for pairwise
complete observations when there are missing values), and feature
importances are pandas Series for pandas input and dicts otherwise.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…lpers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@solegalli
solegalli force-pushed the narwhals-selection-base branch from 8a105e3 to d25c9df Compare November 21, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant