yobx.sklearn.preprocessing.spline_transformer#

yobx.sklearn.preprocessing.spline_transformer.sklearn_spline_transformer(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: SplineTransformer, X: str, name: str = 'spline_transformer') str[source]#

Converts a sklearn.preprocessing.SplineTransformer into ONNX.

The implementation evaluates the B-spline design matrix feature-by-feature using precomputed piecewise-polynomial coefficients (one polynomial piece per knot interval per basis function). For each input feature the following graph is produced:

x_col (N,)
  │
  ├─Clip(xmin, xmax)──► x_eff (N,)          [only for extrapolation='constant']
  │
  ├─Unsqueeze──LessOrEqual(bp)──Cast──ReduceSum──Sub(1)──Clip ──► seg (N,)
  │                                                                  │
  ├─Gather(bp, seg)──────────────────────────────────────────► bp_seg (N,)
  │
  ├─Sub(bp_seg)──► x_rel (N,)
  │
  ├─Unsqueeze──Pow(powers)──► poly_basis (N, d+1)
  │
  Gather(coeff, seg)──► gathered (N, n_splines, d+1)
  │
  MatMul(Unsqueeze(poly_basis), Transpose(gathered))──Squeeze ──► dm_i (N, n_splines)

All per-feature design matrices are concatenated along axis 1. When include_bias=False, the last spline column of each feature block is dropped via a Gather on axis 1.

Supported extrapolation modes:

  • 'constant' (default) — clamp the input to the training range; values outside the range receive the boundary basis-function values.

  • 'continue' — continue the polynomial of the boundary interval; no clamping is applied.

Other modes ('error', 'linear', 'periodic') are not yet supported.

Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • estimator – a fitted SplineTransformer

  • outputs – desired output names

  • X – input tensor name

  • name – prefix name for the added nodes

Returns:

output tensor name

Raises:

NotImplementedError – for unsupported extrapolation modes or interaction_only=True