cleverly.bases.Linear#

class cleverly.bases.Linear(columns: Sequence[str], intercept: bool = True)[source]#

Each modifier as it is, beside an intercept. Needs no domain.

Parameters:
columnssequence of str

The continuous (or 0/1) modifiers, one design column each.

interceptbool

Whether to prepend the intercept column.

Examples

>>> from cleverly.bases import Linear
>>> basis = Linear(["W1", "W3"])
>>> basis.terms
('(intercept)', 'W1', 'W3')
>>> basis.evaluate({"W1": [0.5, -1.0], "W3": [2.0, 0.0]}).tolist()
[[1.0, 0.5, 2.0], [1.0, -1.0, 0.0]]

Methods#

Linear.truncate(k: int) → Linear[source]#

Return this basis: a linear term has one size.

Parameters:
kint

A size of at least one.

Returns:
Linear

This basis.

Attributes#

Linear.intercept: bool = True#
Linear.columns: Sequence[str]#

The modifier columns the basis reads: a field or a property of each subclass.