DeepGAM Engineering & Sequential Encapsulation [EXP]¶
🧪 Experimental – Work in Progress
⚠️ Status: Incomplete / exploratory code
This module is under heavy development or prototyping
It may be partially implemented or non-functional
Behavior, correctness, and API are not guaranteed
Provided for transparency and research exploration only
Navigation:
Theory introduction: See the Intro
Related mathematical theory: See the Mathematical Theory
Backfitting and the validation guard¶
NeuralTAM first fits its StaticTAM, where an n() term is a frozen random-feature effect solved in closed form. It then trains one network per group and per n() term by backfitting:
the partial residual of a network is the target minus the other effects (the closed-form contribution of that network is added back), the network is trained on it, and the best epoch by validation loss is kept.
The closed-form column of a network is the column of the base decomposition named after the effect:
effect_xwhen the network is the only term onx,effect_n_xwhenxalso has as()orl()term.neural_effect_columns(effects)returns it for every network; the backfitting starts from that contribution.The guard (
guard=True, the default): once a network is trained, its validation loss is compared with the loss of the closed-form contribution it would replace, on the same validation rows (the rows ofdata_valwhen given, otherwise the lastval_splitfraction of the group). The network is kept only if its loss is strictly lower. Otherwise the closed-form column stays in the forecast and the decomposition,mlps_has no entry for that group and feature, andnetwork_used_[group][feature]isFalse.When no network is kept anywhere, the model equals its
StaticTAMand aUserWarningsays so: give the networks more epochs or neurons, or passguard=Falseto keep them anyway. A short training (a few epochs, a small network) usually ends there, which is why aNeuralTAMis never worse than itsStaticTAMby more than the noise of the validation rows.guard=Falsekeeps every network, as the model did before the guard existed.Training of each network: Adam at the fixed learning rate
lr, the best epoch by validation loss, and early stopping afterpatienceepochs without improvement. There is no learning-rate scheduler: the last layer starts at zero, so the validation loss is flat for the first epochs, and a plateau scheduler used to halve the rate to its floor before the network had moved.