Skip to main content

models.Coding

Terms with factor levels learned from training data, from

Usage

Source

models.Coding()

Attributes

Name Description
names Design matrix column names.

names

Design matrix column names.

names: list[str]

Methods

Name Description
design() The design matrix for data.
from_json() Reads an artifact written by to_json.
to_json() The coding, with the levels and knots training learned, as a versioned JSON artifact (format

design()

The design matrix for data.

Usage

Source

design(data, offset=None, weights=None)
Parameters
data: dict of str to list
offset: list of float = None
weights: list of float = None
Returns
Design
Raises
ValueError
If a column is missing or a factor level was not seen in training.

from_json()

Reads an artifact written by to_json.

Usage

Source

from_json(text)
Parameters
text: str
Returns
Coding
Raises
ValueError
For malformed JSON, another format, a newer format version or an invalid term.

to_json()

The coding, with the levels and knots training learned, as a versioned JSON artifact (format

Usage

Source

to_json()

risk_rs.coding), numbers bit for bit (#978). from_json reads it back; pickle uses the same document.

Returns
str
Examples
>>> import pickle
>>> from prospicio.models import Coding, Terms
>>> data = {"age": [30.0, 45.0, 60.0], "region": ["N", "S", "W"]}
>>> coding = Terms().intercept().numeric("age").factor("region").fit(data)
>>> back = pickle.loads(pickle.dumps(coding))
>>> back.names

[‘(Intercept)’, ‘age’, ‘region[S]’, ‘region[W]’]

>>> Coding.from_json(coding.to_json()).to_json() == coding.to_json()

True