Skip to main content

Module select_from_model

Module select_from_model 

Source
Expand description

Feature selection driven by a model’s feature importance weights.

SelectFromModel provides basic mean/explicit-threshold selection. This module provides a richer API via SelectFromModelExt, which supports four threshold strategies (mean, median, explicit value, percentile) and an optional max_features cap.

§Threshold Strategies

VariantDescription
ThresholdStrategy::MeanThreshold = arithmetic mean of importances
ThresholdStrategy::MedianThreshold = median of importances
ThresholdStrategy::ValueUser-supplied explicit threshold
ThresholdStrategy::PercentileKeep features in the top p% by importance

When max_features is set, at most that many features are retained (in descending importance order) regardless of the threshold.

§REQ status

Translation target: scikit-learn 1.5.2 class SelectFromModel (sklearn/feature_selection/_from_model.py:256). Tracking: #1352. Each REQ is BINARY — SHIPPED (impl + non-test consumer + tests + green verification) or NOT-STARTED (with a concrete open blocker). HONEST scope: this unit ships the threshold + selection-mask + max_features core GIVEN a static importance vector; sklearn wraps a fitted estimator and extracts its importances — that estimator machinery is NOT-STARTED.

REQScopeStatusEvidence / Blocker
REQ-1Threshold (mean/median/value) + selection mask (score >= threshold) + max_features top-k cap, given a static importance vectorSHIPPEDSelectFromModelExt fit matches sklearn _get_support_mask _from_model.py:299-312 + _calculate_threshold :24-71 (mean=np.mean, median=np.median); threshold-then-cap is algebraically equivalent to sklearn cap-then-threshold (exhaustive-grid oracle-verified); 15 oracle value tests in tests/divergence_select_from_model.rs. Consumer: boundary re-export lib.rs (grandfathered S5/R-DEFER-1) + PipelineTransformer
REQ-2Error/parameter contracts (empty importances, Percentile range, transform ncols mismatch)SHIPPED (scoped)SelectFromModelExt::fit/FittedSelectFromModelExt transform; in-module + divergence error tests
REQ-3Estimator wrapping + coef_/feature_importances_ extraction (_get_feature_importances)NOT-STARTEDtakes importances directly; sklearn _from_model.py:299-304 — blocker #1353
REQ-4norm_order multi-output coef normNOT-STARTEDscalar importances only; sklearn _from_model.py:303 — blocker #1354
REQ-5Scaled-string scale*mean/scale*median thresholds + default-from-estimator (l1→1e-5)NOT-STARTEDsklearn _from_model.py:30-55 — blocker #1355
REQ-6prefit + importance_getter paramsNOT-STARTEDsklearn _from_model.py:256-271,277-284 — blocker #1356
REQ-7max_features callable + _check_max_features range validation [0, n_features]NOT-STARTEDint cap only; sklearn _from_model.py:315-331 — blocker #1357
REQ-8SelectorMixin surface (get_support/inverse_transform/get_feature_names_out)NOT-STARTEDsklearn _base.py SelectorMixin — blocker #1358
REQ-9PyO3 bindingNOT-STARTEDno ferrolearn-python registration — blocker #1359
REQ-10ferray substrateNOT-STARTEDdense Array2 + num_traits::Float only — blocker #1360

NOTE: ThresholdStrategy::Percentile is a ferrolearn EXTENSION with NO sklearn SelectFromModel analog (sklearn supports only mean/median/scale*ref/ float); it is not a sklearn-parity REQ and carries no blocker.

Structs§

FittedSelectFromModelExt
A fitted model-importance selector produced by SelectFromModelExt::fit.
SelectFromModelExt
An extended model-importance-based feature selector.

Enums§

ThresholdStrategy
Strategy for computing the importance threshold in SelectFromModelExt.