## models.Cann


A Combined Actuarial Neural Network (Wüthrich and Merz): the design's


Usage

``` python
models.Cann()
```


offset, a GLM's linear predictor, plus a feed-forward network of the design's columns, `eta = offset + NN(x)`.

The output layer starts at zero, so training starts exactly at the GLM and learns only what it misses. Training minimizes the family's weighted deviance by Adam on mini-batches, on the CPU in `float64`, and is reproducible from [seed](aggregate.EventSet.md#prospicio.aggregate.EventSet.seed).


## Parameters


`family: (poisson, gamma, tweedie, gaussian) = ``"poisson"`  

`link: str`  
`"log"` for the Poisson, gamma and Tweedie, `"identity"` for the Gaussian: the only links supported, and the defaults.

`hidden: list of int = [16, 8]`  
Widths of the hidden ReLU layers.

`epochs: int = ``200`  

`batch_size: int = ``64`  

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

`seed: int = ``0`  
Seeds the initial weights and the mini-batch order.

`validation_share: float`  
Turns on early stopping: hold out this share of the rows, score the mean deviance on them after each epoch, and keep the best epoch.

`patience: int = ``10`  
With early stopping, epochs without improvement before stopping.

`power: float`  
The Tweedie power.


## Examples

``` python
>>> from prospicio.models import Cann, Design
>>> x = [i / 50 - 1 for i in range(100)]
>>> d = Design([x], ["x"], offset=[0.0] * 100)
>>> fit = Cann("poisson", hidden=[8], epochs=5, seed=1).fit(d, [1.0] * 100)
>>> len(fit.predict(d))
```

100


## Methods

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

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


#### fit()


Fits the network.


Usage

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


##### Parameters


`design: Design`  
Columns are standardized internally; the offset carries the GLM's linear predictor (zeros for a network alone).

`y: list of float`  


##### Returns


`CannFit`  


##### Raises


`ValueError`  
If the family or link is not supported, a setting is out of range, or a response is out of the family's range.
