models.AttentionCann
A CANN whose correction is a transformer over feature tokens (an
Usage
models.AttentionCann()FT-Transformer in the CANN setting).
Each numeric column is a token, and each factor’s indicator columns (region[B], region[C], …) together form one token. A learned [CLS] token joins them; pre-norm blocks of multi-head self-attention and a feed-forward layer mix them; the [CLS] state, through a zero-initialized head, corrects the linear predictor, so training starts exactly at the GLM.
Parameters
family: (poisson, gamma, tweedie, gaussian) = "poisson"link: str-
As for Cann: log, or identity for the Gaussian.
d_model: int = 16-
Token width; a multiple of heads.
heads: int = 2layers: int = 2-
Transformer blocks.
feed_forward: int = 32-
Width of each block’s feed-forward layer.
epochs: int = 100batch_size: int = 64learning_rate: float = 1e-3seed: int = 0validation_share: float-
Turns on early stopping, as for Cann.
patience: int = 10power: float- The Tweedie power.
Methods
| Name | Description |
|---|---|
| fit() | Fits the network. |
fit()
Fits the network.
Usage
fit(design, y)Parameters
design: Designy: list of float
Returns
AttentionCannFit
Raises
ValueError-
If the family or link is not supported,
d_modelis not a multiple of heads, or a response is out of range.