yobx.sklearn.decomposition.pls_regression#

yobx.sklearn.decomposition.pls_regression.sklearn_pls_regression(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: PLSRegression, X: str, name: str = 'pls_regression') str[source]#

Converts a sklearn.cross_decomposition.PLSRegression into ONNX.

The prediction formula mirrors PLSRegression.predict():

X  ──Sub(_x_mean)──►  centered  ──Gemm(coef_.T, intercept_)──►  y_pred
                                                                      │
                                                 (if _predict_1d) Squeeze──►  output
                                                                      │
                                                (if not _predict_1d) └──────►  output

The input is centred by subtracting _x_mean, then the prediction is computed as y_pred = centered @ coef_.T + intercept_. For single-target models (_predict_1d is True) the output is squeezed to shape (N,); for multi-target models the output shape is (N, n_targets).

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

  • sts – shapes defined by scikit-learn

  • estimator – a fitted PLSRegression

  • outputs – desired output names (predictions)

  • X – input tensor name

  • name – prefix name for the added nodes

Returns:

output tensor name

Note

discrepancies

The conversion shows discrepancies for scikit-learn==1.4 at least in unit tests. It is safe to assume it only works for scikit-learn>=1.8.