## models.AttentionCann


A CANN whose correction is a transformer over feature tokens (an


Usage

``` python
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](models.Cann.md#prospicio.models.Cann): log, or identity for the Gaussian.

`d_model: int = ``16`  
Token width; a multiple of [heads](models.TokenAttention.md#prospicio.models.TokenAttention.heads).

`heads: int = ``2`  

`layers: int = ``2`  
Transformer blocks.

`feed_forward: int = ``32`  
Width of each block's feed-forward layer.

`epochs: int = ``100`  

`batch_size: int = ``64`  

`learning_rate: float = ``1e-3`  

`seed: int = ``0`  

`validation_share: float`  
Turns on early stopping, as for [Cann](models.Cann.md#prospicio.models.Cann).

`patience: int = ``10`  

`power: float`  
The Tweedie power.


## Methods

| Name | Description |
|----|----|
| [fit()](#fit) | Fits the network. |

------------------------------------------------------------------------


#### fit()


Fits the network.


Usage

``` python
fit(design, y)
```


##### Parameters


`design: Design`  

`y: list of float`  


##### Returns


`AttentionCannFit`  


##### Raises


`ValueError`  
If the family or link is not supported, `d_model` is not a multiple of [heads](models.TokenAttention.md#prospicio.models.TokenAttention.heads), or a response is out of range.
