## models.TweedieFit


A Tweedie GLM with its power estimated, from [TweedieGlm.fit](models.TweedieGlm.md#prospicio.models.TweedieGlm.fit).


Usage

``` python
models.TweedieFit()
```


## Attributes

| Name | Description |
|----|----|
| [at_boundary](#at_boundary) | Whether the power is at a search bound. |
| [dispersion](#dispersion) | The maximum-likelihood dispersion at that power. |
| [glm](#glm) | The GLM at the estimated power, its dispersion fixed at the estimate. |
| [interval](#interval) | The 95% profile-likelihood interval for the power. |
| [interval_open](#interval_open) | Whether each end of [interval](models.TweedieFit.md#prospicio.models.TweedieFit.interval) is a search bound rather than a |
| [log_likelihood](#log_likelihood) | The maximized log-likelihood. |
| [power](#power) | The maximum-likelihood power. |

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


#### at_boundary


Whether the power is at a search bound.


`at_boundary: bool`


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


#### dispersion


The maximum-likelihood dispersion at that power.


`dispersion: float`


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


#### glm


The GLM at the estimated power, its dispersion fixed at the estimate.


`glm: GlmFit`


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


#### interval


The 95% profile-likelihood interval for the power.


`interval: tuple[float, float]`


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


#### interval_open


Whether each end of [interval](models.TweedieFit.md#prospicio.models.TweedieFit.interval) is a search bound rather than a


`interval_open: tuple[bool, bool]`


crossing.


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


#### log_likelihood


The maximized log-likelihood.


`log_likelihood: float`


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


#### power


The maximum-likelihood power.


`power: float`


## Methods

| Name | Description |
|----|----|
| [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). |
| [to_json()](#to_json) | The fit as a versioned JSON artifact (format |

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


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


`TweedieFit`  


##### Raises


`ValueError`  
For malformed JSON, another format, a newer format version or inconsistent fields.


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


#### predict()


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


Usage

``` python
predict(design)
```


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


#### to_json()


The fit as a versioned JSON artifact (format


Usage

``` python
to_json()
```


`risk_rs.tweedie_fit`): the power and dispersion, the profile's interval and evaluations, and the GLM at that power as a nested `risk_rs.glm_fit` artifact, numbers bit for bit (#978). [from_json](models.Terms.md#prospicio.models.Terms.from_json) reads it back; `pickle` uses the same document.


##### Returns


`str`  


##### Examples

``` python
>>> import pickle
>>> from prospicio.models import Design, TweedieFit, TweedieGlm
>>> x = [float(i % 3) for i in range(60)]
>>> y = [0.0 if i % 4 == 0 else 1.0 + (i * 7) % 5 + x[i] for i in range(60)]
>>> d = Design([[1.0] * 60, x], ["(Intercept)", "x"])
>>> fit = TweedieGlm().fit(d, y)
>>> TweedieFit.from_json(fit.to_json()).power == fit.power
```

True

``` python
>>> pickle.loads(pickle.dumps(fit)).to_json() == fit.to_json()
```

True
