Skip to main content

models.TweedieFit

A Tweedie GLM with its power estimated, from TweedieGlm.fit.

Usage

Source

models.TweedieFit()

Attributes

Name Description
at_boundary Whether the power is at a search bound.
dispersion The maximum-likelihood dispersion at that power.
glm The GLM at the estimated power, its dispersion fixed at the estimate.
interval The 95% profile-likelihood interval for the power.
interval_open Whether each end of interval is a search bound rather than a
log_likelihood The maximized log-likelihood.
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 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() Reads an artifact written by to_json.
predict() Expected response for each row of design.
to_json() The fit as a versioned JSON artifact (format

from_json()

Reads an artifact written by to_json.

Usage

Source

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.

Usage

Source

predict(design)

to_json()

The fit as a versioned JSON artifact (format

Usage

Source

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 reads it back; pickle uses the same document.

Returns
str
Examples
>>> 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

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

True