yobx.sklearn.category_encoders.target_encoder#
- yobx.sklearn.category_encoders.target_encoder.category_encoders_target_encoder(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: TargetEncoder, X: str, name: str = 'target_encoder') str[source]#
Converts a
category_encoders.TargetEncoderinto ONNX.The encoder replaces each categorical column with the smoothed mean of the target distribution conditioned on that category value. Non-categorical columns pass through unchanged.
X ──col_j (categorical)──► Equal(val_i)?──► target_mean_i ... IsNaN?──────────► nan_target default──────────► unknown_target X ──col_k (numerical)──► unchangedThe conversion pre-computes a combined lookup table (original category value → smoothed target mean) from the fitted
ordinal_encoderandmappingattributes. Unknown categories and NaN inputs are handled via separateWherenodes that override the default value.- Parameters:
g – the graph builder to add nodes to
sts – shapes defined by scikit-learn
estimator – a fitted
TargetEncoderoutputs – desired output names
X – input name (shape
(N, F))name – prefix name for the added nodes
- Returns:
output name