Problem
Feature Selection Pipeline max_features parameter is ignored when building a pipeline with HyperparameterRooting.
the configured cap is not effectively enforced at runtime.
Root Cause (Hypothesis)
MotherSelectFromModel receives max_features through **kwargs instead of an explicit __init__ parameter.
sklearn pipelines clone estimators internally during fit using:
get_params(deep=False)
- Reconstruct estimator from returned params
BaseEstimator.get_params() only inspects the current class __init__ signature. Because max_features is not explicitly declared in MotherSelectFromModel.__init__, it is missing from get_params().
As a result, the cloned selector is rebuilt with max_features=None, so the cap is silently dropped.
Suggested Fix
Add max_features explicitly to MotherSelectFromModel.__init__ (instead of only passing via **kwargs) in file ml/models/estimators.py:
class MotherSelectFromModel(SelectFromModel, ml.AbstractMotherPipeline):
def __init__(
self,
estimator,
threshold=np.finfo(np.float64).tiny,
max_features=None, # explicit argument
**kwargs,
):
super().__init__(
estimator=estimator,
threshold=threshold,
max_features=max_features,
**kwargs,
)
This keeps max_features visible to get_params(), so sklearn clone() preserves it.
Working Workaround
By using a thin local wrapper that explicitly exposes max_features in the __init__ the problem is solved.
class _SelectFromModelWithMaxFeatures(MotherSelectFromModel):
def __init__(self, estimator, threshold=np.finfo(np.float64).tiny, max_features=None, **kwargs):
super().__init__(
estimator=estimator,
threshold=threshold,
max_features=max_features,
**kwargs,
)
Then instantiate this wrapper instead of MotherSelectFromModel in _create_feature_selection_pipeline.
Problem
Feature Selection Pipeline
max_featuresparameter is ignored when building a pipeline with HyperparameterRooting.the configured cap is not effectively enforced at runtime.
Root Cause (Hypothesis)
MotherSelectFromModelreceivesmax_featuresthrough**kwargsinstead of an explicit__init__parameter.sklearnpipelines clone estimators internally duringfitusing:get_params(deep=False)BaseEstimator.get_params()only inspects the current class__init__signature. Becausemax_featuresis not explicitly declared inMotherSelectFromModel.__init__, it is missing fromget_params().As a result, the cloned selector is rebuilt with
max_features=None, so the cap is silently dropped.Suggested Fix
Add
max_featuresexplicitly toMotherSelectFromModel.__init__(instead of only passing via**kwargs) in fileml/models/estimators.py:This keeps
max_featuresvisible toget_params(), so sklearnclone()preserves it.Working Workaround
By using a thin local wrapper that explicitly exposes
max_featuresin the__init__the problem is solved.Then instantiate this wrapper instead of
MotherSelectFromModelin_create_feature_selection_pipeline.