yobx.sklearn.linear_model.linear_regressor#

yobx.sklearn.linear_model.linear_regressor.sklearn_linear_regressor(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: LinearRegression | Ridge, X: str, name: str = 'linear_regressor') str[source]#

Converts any plain sklearn linear regressor into ONNX.

All supported estimators share the same prediction formula:

y = X @ coef_.T + intercept_

The mapping covers LinearRegression, Ridge, Lasso, ElasticNet and many more (see _LINEAR_REGRESSOR_TYPES).

Graph structure:

X  ──Gemm(coef, intercept, transB=1)──►  predictions

For single-output models the output shape is (N, 1); for multi-output models it is (N, n_targets).

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

  • sts – shapes defined by scikit-learn

  • outputs – desired output names

  • estimator – a fitted linear regressor

  • X – input tensor name

  • name – prefix for added node names

Returns:

output tensor name