yobx.sklearn.dummy.dummy#

yobx.sklearn.dummy.dummy.sklearn_dummy_classifier(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: DummyClassifier, X: str, name: str = 'dummy_classifier') Tuple[str, str][source]#

Converts a sklearn.dummy.DummyClassifier into ONNX.

The converter supports the deterministic strategies most_frequent, prior, and constant. The randomised strategies stratified and uniform are not supported because they produce non-deterministic outputs that cannot be expressed as a static ONNX graph.

For the supported strategies the predicted probability row and the predicted class are constant for every sample, so the graph simply broadcasts those constants to match the batch dimension:

X  ──Shape──Slice([0:1])──────────────────────────► batch_size [N]
                                                         │
proba_row (1, n_classes) ──────────Expand ───────────────┤
                                       │                 │
                                   proba (N, n_classes)  │
                                                     Expand
class_const (1,) ──────────────────────────────────────► label (N,)
Parameters:
  • g – the graph builder to add nodes to

  • sts – shapes defined by scikit-learn

  • outputs – desired output names [label, probabilities]

  • estimator – a fitted DummyClassifier

  • X – input tensor name

  • name – prefix for added node names

Returns:

tuple (label_name, proba_name)

Raises:
yobx.sklearn.dummy.dummy.sklearn_dummy_regressor(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: DummyRegressor, X: str, name: str = 'dummy_regressor') str[source]#

Converts a sklearn.dummy.DummyRegressor into ONNX.

All supported strategies (mean, median, quantile, constant) store the prediction constant in estimator.constant_ after fitting, so the ONNX graph simply broadcasts that constant to match the batch dimension of the input.

Graph structure for single-output models:

X  ──Shape──Slice([0:1])──────────────────────► batch_size [N]
                                                     │
constant_ (1,)  ───────────────────Expand ──────────┘
                                       │
                                   result (N,)

For multi-output models the constant is (1, n_outputs) and the output shape is (N, n_outputs).

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

  • sts – shapes defined by scikit-learn

  • outputs – desired output names

  • estimator – a fitted DummyRegressor

  • X – input tensor name

  • name – prefix for added node names

Returns:

output tensor name