yobx.sklearn.impute.simple_imputer#

yobx.sklearn.impute.simple_imputer.sklearn_simple_imputer(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: SimpleImputer, X: str, name: str = 'simple_imputer') str[source]#

Converts a sklearn.impute.SimpleImputer into ONNX.

All four strategies (mean, median, most_frequent, constant) store the per-feature fill value in estimator.statistics_ after fitting, so the ONNX graph only needs to detect missing entries and replace them with those constants.

Graph structure when missing_values is numpy.nan (the default):

X ──IsNaN──► nan_mask [N, F]
                  │
statistics_ ──────┼──► Where ──► output
                  │
X ─────────────────┘

When missing_values is a numeric value the IsNaN node is replaced by an Equal node:

X ──Equal(missing_values)──► mask [N, F]
                                 │
statistics_ ─────────────────────┼──► Where ──► output
                                 │
X ─────────────────────────────────┘

add_indicator=True is not supported and raises NotImplementedError.

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

  • sts – shapes defined by scikit-learn

  • estimator – a fitted SimpleImputer

  • outputs – desired output names

  • X – input name

  • name – prefix name for the added nodes

Returns:

output name