## models.CannFit


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


Usage

``` python
models.CannFit()
```


## 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 on the |
| [fitted](#fitted) | Fitted means on the training rows. |
| [input_hash](#input_hash) | Hash of the training data (design, offset, weights, response). |
| [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 on the


`dispersion: float`


training data.


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


#### fitted


Fitted means on the training rows.


`fitted: list[float]`


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


#### input_hash


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


`input_hash: str`


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


#### validation_history


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


`validation_history: list[float]`


## Methods

| Name | Description |
|----|----|
| [correction()](#correction) | The network's correction to the linear predictor, `NN(x)`, 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) (same columns as the |
| [predict_distribution()](#predict_distribution) | Joint predictive distribution across the rows, keyed \`\`row = 0, 1, |
| [to_json()](#to_json) | The fit as a JSON artifact (spec, scaling, every weight by its path, |

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


#### correction()


The network's correction to the linear predictor, `NN(x)`, 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


`CannFit`  


##### 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) (same columns as the


Usage

``` python
predict(design)
```


training design), `g^-1(offset + NN(x))`.


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


#### predict_distribution()


Joint predictive distribution across the rows, keyed \`\`row = 0, 1,


Usage

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


…\`\`: process draws from the family around the predicted means (a trained network carries no parameter uncertainty).


##### 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`  


##### Examples

``` python
>>> import pickle
>>> from prospicio.models import Cann, Design
>>> d = Design([[0.0, 1.0, 2.0, 3.0]], ["x"])
>>> fit = Cann("poisson", hidden=[4], epochs=5).fit(d, [1.0, 2.0, 2.0, 5.0])
>>> pickle.loads(pickle.dumps(fit)).predict(d) == fit.predict(d)
```

True
