pyGAM
pyGAM copied to clipboard
Fix #545: Resolve empty Effective DoF in summary() for overparameterized models
Fixes #545
Description
This PR fixes the bug where the Effective Degrees of Freedom (EDoF) per term in summary() is printed as an empty string for overparameterized models (where the number of samples is less than the number of coefficients).
Changes Made
- Modify
summary()inpygam.pyto correctly fall back tofloat("nan")instead of""for overparameterized models so the summary table is properly formatted. -
- Add a
warnings.warnspecifically calling out that the model is overparameterized and the EDoF per term cannot be reliably computed.
- Add a
-
- Optimization/Vectorization: Replaced
np.diagonal(U1.dot(U1.T))with(U1**2).sum(axis=1)to avoid calculating a full dense matrix just to slice the diagonal, improving efficiency while maintaining identical results.
- Optimization/Vectorization: Replaced
-
- Updated test assertions in
tests/test_GAM_methods.pyto capture this warning properly. All existing tests pass correctly.
- Updated test assertions in