## models.AttentionCannFit


A fitted attention CANN, from [AttentionCann.fit](models.AttentionCann.md#prospicio.models.AttentionCann.fit).


Usage

``` python
models.AttentionCannFit()
```


## Attributes

| Name | Description |
|----|----|
| [best_epoch](#best_epoch) | With early stopping, the epoch (from 1) whose network was kept. |
| [dispersion](#dispersion) | Dispersion: 1 for the Poisson, otherwise Pearson's estimate. |
| [fitted](#fitted) | Fitted means on the training rows. |
| [input_hash](#input_hash) | Hash of the training data (design, offset, weights, response). |
| [tokens](#tokens) | Feature tokens, in column order. |
| [validation_history](#validation_history) | With early stopping, the validation mean deviance after each epoch. |

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


#### best_epoch


With early stopping, the epoch (from 1) whose network was kept.


`best_epoch: int | None`


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


#### dispersion


Dispersion: 1 for the Poisson, otherwise Pearson's estimate.


`dispersion: float`


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


#### fitted


Fitted means on the training rows.


`fitted: list[float]`


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


#### input_hash


Hash of the training data (design, offset, weights, response).


`input_hash: str`


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


#### tokens


Feature tokens, in column order.


`tokens: list[str]`


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


#### validation_history


With early stopping, the validation mean deviance after each epoch.


`validation_history: list[float]`


## Methods

| Name | Description |
|----|----|
| [attention()](#attention) | The last block's attention from `[CLS]` to each feature token, per |
| [correction()](#correction) | The network's correction to the linear predictor, per row. |
| [from_json()](#from_json) | Reads an artifact written by [to_json](models.Terms.md#prospicio.models.Terms.to_json). |
| [predict()](#predict) | Expected response for each row of [design](models.Coding.md#prospicio.models.Coding.design). |
| [predict_distribution()](#predict_distribution) | Joint predictive distribution across the rows: process draws from |
| [to_json()](#to_json) | The fit as a JSON artifact (spec, scaling, every weight by its path, |

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


#### attention()


The last block's attention from `[CLS]` to each feature token, per


Usage

``` python
attention(design)
```


row of [design](models.Coding.md#prospicio.models.Coding.design) and head: where the model looked for each risk. A diagnostic, not a decomposition of the prediction.


##### Returns


`TokenAttention`  


##### Raises


`ValueError`  
If the model has no blocks (`layers=0`).


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


#### correction()


The network's correction to the linear predictor, per row.


Usage

``` python
correction(design)
```


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


#### from_json()


Reads an artifact written by [to_json](models.Terms.md#prospicio.models.Terms.to_json).


Usage

``` python
from_json(text)
```


##### Parameters


`text: str`  


##### Returns


`AttentionCannFit`  


##### Raises


`ValueError`  
For malformed JSON, another format, a newer format version or weights that do not fit the spec.


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


#### predict()


Expected response for each row of [design](models.Coding.md#prospicio.models.Coding.design).


Usage

``` python
predict(design)
```


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


#### predict_distribution()


Joint predictive distribution across the rows: process draws from


Usage

``` python
predict_distribution(design, n_sims, seed)
```


the family around the predicted means.


##### Parameters


`design: Design`  

`n_sims: int`  

`seed: int`  


##### Returns


`PredictiveDistribution`  


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


#### to_json()


The fit as a JSON artifact (spec, scaling, every weight by its path,


Usage

``` python
to_json()
```


fitted values, provenance); [from_json](models.Terms.md#prospicio.models.Terms.from_json) reads it back exactly and pickling uses it too.


##### Returns


`str`
