yobx.sklearn.multioutput.regressor_chain#
- yobx.sklearn.multioutput.regressor_chain.sklearn_regressor_chain(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: RegressorChain, X: str, name: str = 'regressor_chain') str[source]#
Converts a
sklearn.multioutput.RegressorChaininto ONNX.The converter iterates over the fitted sub-estimators in chain order. Each sub-estimator
ireceives an augmented feature matrix formed by concatenating the original inputXwith all previous predictions along axis 1. The prediction of every sub-estimator is reshaped from(N,)to(N, 1)before being appended to the running feature matrix.After all sub-estimators have been applied the per-chain predictions are concatenated into a
(N, n_targets)tensor in chain order. Whenestimator.order_is not the identity permutation a finalGathernode reorders the columns to match the original target order.Graph structure (default order, 3 targets):
X ───────────────────── [est 0] ──► pred_0 (N,) ──Reshape(N,1)──► p0 Concat(X, p0) ────────── [est 1] ──► pred_1 (N,) ──Reshape(N,1)──► p1 Concat(X, p0, p1) ────── [est 2] ──► pred_2 (N,) ──Reshape(N,1)──► p2 Concat(p0, p1, p2, axis=1) ──► chain_preds (N, n_targets) │ Gather(chain_preds, inv_order, axis=1) ──► predictions (N, n_targets)- Parameters:
g – the graph builder to add nodes to
sts – shapes and types defined by scikit-learn
outputs – desired output tensor names
estimator – a fitted
RegressorChainX – name of the input tensor
name – prefix used for names of nodes added by this converter
- Returns:
name of the output tensor of shape
(N, n_targets)