TensorInteraction#
- class superglm.TensorInteraction(
- feat1_name: str,
- feat2_name: str,
- *,
- n_knots: tuple[int, int] | None = None,
- decompose: bool = False,
Bases:
objectInteraction-only tensor product spline (ti) term.
Builds centered marginal bases from parent spline specs, inheriting their knot vectors, penalties, and boundary constraints. Forms the row-wise Kronecker product to yield an interaction-only surface: constant and main-effect directions are excluded structurally.
The tensor penalty is
kron(S1, I) + kron(I, S2)on the centered marginals. This leaves the bilinearx1 * x2direction in the tensor null space while excluding the constant,x1andx2lower-order pieces. Group lasso can still zero the whole interaction block cleanly.- Parameters:
- feat1_name, feat2_namestr
Names of the parent spline features.
- n_knotstuple of int or None
(n_knots1, n_knots2)interior knots for each marginal basis. When None (default), the parent’s knot count is used directly.- decomposebool
If True, split the centered tensor basis into a 1D bilinear subgroup and a wiggly subgroup. This is useful when you want the bilinear null space to be selectable/shrinkable separately from the higher-order interaction surface.
- build_discrete(
- x1: NDArray,
- x2: NDArray,
- parent_specs: dict,
- n_bins: tuple[int, int],
- sample_weight: NDArray | None = None,
Build a discretized tensor basis on observed joint support pairs.
- score(
- x1: NDArray,
- x2: NDArray,
- beta: NDArray,
Score the tensor interaction without materialising the row-Kronecker block.