ConstraintSpec#

class superglm.ConstraintSpec(
mode: Literal['fit', 'postfit'],
kind: Literal['increasing', 'decreasing', 'convex', 'concave', 'flat', 'cap', 'max_step'],
lo: float | str | None = None,
hi: float | str | None = None,
bounds: tuple[float, float] | None = None,
)#

Bases: object

A single shape rule: when it is applied, and what it requires.

lo and hi bound the stretch of the feature the rule applies to (None is unbounded; an end is a number or an ordered-categorical band label). bounds carries the two numbers of a cap (lo, hi) or a max_step (up, down). Rules join with & into ConstraintRules.

below(x: float | str) → ConstraintSpec#

Apply the rule up to x only.

above(x: float | str) → ConstraintSpec#

Apply the rule from x upward only.

within(
a: float | str,
b: float | str,
) → ConstraintSpec#

Apply the rule between a and b only.