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.DummyClassifierinto ONNX.The converter supports the deterministic strategies
most_frequent,prior, andconstant. The randomised strategiesstratifiedanduniformare 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
DummyClassifierX – input tensor name
name – prefix for added node names
- Returns:
tuple
(label_name, proba_name)- Raises:
NotImplementedError – when
strategyis"stratified"or"uniform"NotImplementedError – when the estimator has more than one output
- 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.DummyRegressorinto ONNX.All supported strategies (
mean,median,quantile,constant) store the prediction constant inestimator.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
DummyRegressorX – input tensor name
name – prefix for added node names
- Returns:
output tensor name