Description
Currently, pyGAM estimators fail to properly route nested parameters. Because set_params() does not recursively handle scikit-learn's double-underscore (__) routing syntax, nested parameters are silently ignored.
This results in a critical silent failure: users running GridSearchCV over a range of term-specific parameters (e.g., varying n_splines) are unknowingly evaluating the exact same default model repeatedly, as the terms never actually update.
Steps to Reproduce
from pygam import LinearGAM, s
gam = LinearGAM(s(0, n_splines=10))
# Scikit-Learn meta-estimators tune nested parameters using this syntax:
gam.set_params(terms__0__n_splines=30)
# The parameter is silently ignored. The term remains unchanged.
assert gam.terms[0].n_splines == 10
So any hyperparameter tuning on specific terms via Pipeline or GridSearchCV is currently a placebo.
I think we can override set_params in GAM to intercept kwargs containing __. Split the key, resolve the target object within the TermList, and apply setattr directly to the nested term.
Description
Currently,
pyGAMestimators fail to properly route nested parameters. Becauseset_params()does not recursively handle scikit-learn's double-underscore (__) routing syntax, nested parameters are silently ignored.This results in a critical silent failure: users running
GridSearchCVover a range of term-specific parameters (e.g., varyingn_splines) are unknowingly evaluating the exact same default model repeatedly, as the terms never actually update.Steps to Reproduce
So any hyperparameter tuning on specific terms via Pipeline or GridSearchCV is currently a placebo.
I think we can override
set_paramsin GAM to intercept kwargs containing__. Split the key, resolve the target object within the TermList, and apply setattr directly to the nested term.