Description
I am trying to set the hyperparameters of the base_estimator
of an AdaBoostRegressor
inside a MultioutputRegressor
. I've defined a parameters dictionary as:
params = {'estimator__base_estimator': DecisionTreeRegressor(),
'estimator__loss': 'square',
'estimator__learning_rate': 0.05,
'estimator__n_estimators': 50,
'estimator__base_estimator__max_features': 'sqrt',
'estimator__base_estimator__max_leaf_nodes': 8
}
The values here aren't important, just the keys. When I call set_params(**params)
it uses get_params
with deep=True
to find the parameters of the model and the sub-model. Great, except I also need to be able to tell the parameters of the sub-sub-model are valid and then set them.
I see that get_params
calls itself but doesn't pass down deep=True
, so I copied and used a version of my own where I did pass deep
down. The trouble I ran in to then was that the sub-sub-model is a parameter of the sub-model and hasn't been set yet, so somewhere down the stack the call value.get_params(deep=True).items()
fails when value
is None
, because value
is the base_estimator
of the AdaboostRegressor
and hasn't been set yet.
I managed to hack a workaround in my code by only passing the parameters that have keys with less than two '__'
substrings and then setting the subobject with the other subset of the params
dictionary, but I would really like it if set_params()
were truly completely generalized to arbitrarily deep structures. This will probably involve intelligently setting objects at each layer before going deeper.