MRFTerm#
- class liesel_gam.MRFTerm(basis, penalty, scale, name='', inference=None, coef_name=None, _update_on_init=True, validate_scalar_scale=True)[source]#
Bases:
StrctTermTerm object for Markov random fields.
Derived from
StrctTerm, with a few additional attributes that give access to information about the Markov random field setup.Examples
MRFTermobjects are usually created byTermBuilder, which also attaches label and neighborhood metadata.>>> import pandas as pd >>> import liesel_gam as gam >>> df = pd.DataFrame({"region": ["a", "b", "a"]}) >>> term = gam.TermBuilder.from_df(df).mrf( ... "region", ... nb={"a": ["b"], "b": ["a"]}, ... absorb_cons=False, ... diagonal_penalty=False, ... scale_penalty=False, ... scale=1.0, ... ) >>> term.neighbors {'a': ['b'], 'b': ['a']} >>> term.labels ['a', 'b']
Attributes
Region labels.
A label-integer mapping for the regions in this term.
Dictionary of neighborhood structure (if available).
Ordered labels, if they are available.
Dictionary of arrays.