yobx.sklearn.category_encoders.basen_encoder#
- yobx.sklearn.category_encoders.basen_encoder.category_encoders_basen_encoder(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: BaseNEncoder, X: str, name: str = 'basen_encoder') str[source]#
Converts a
category_encoders.BaseNEncoderinto ONNX.Each categorical column is replaced by a block of digit columns that encode the ordinal index of the category value in base
N(most significant digit first). Non-categorical columns pass through unchanged.X ──col_j (categorical, K cats)──► digit_0 (MSD) (N, 1) digit_1 (N, 1) ... digit_D (LSD) (N, 1) Concat(digit_0 ... digit_D, axis=1)──► block (N, D) X ──col_k (numerical)──► unchanged (N, 1) Concat(all blocks and pass-through cols, axis=1)──► output (N, F_out)where
Dis the number of base-Ndigits required to represent the largest ordinal andF_outis the total number of output columns.The conversion reads the fitted
mappingattribute (ordinal → digit row) together with theordinal_encoderattribute (category value → ordinal) to determine the per-column digit blocks.Unknown categories (values not seen during training):
handle_unknown='value'(default): all digit columns for that row are 0.handle_unknown='return_nan': all digit columns for that row areNaN.
Missing values (NaN inputs):
handle_missing='value'(default): all digit columns for that row are 0.handle_missing='return_nan': all digit columns for that row areNaN.
- Parameters:
g – the graph builder to add nodes to
sts – shapes defined by scikit-learn
outputs – desired output tensor names
estimator – a fitted
BaseNEncoderX – name of the input tensor (shape
(N, F))name – prefix used for names of nodes added by this converter
- Returns:
name of the output tensor
- Raises:
AssertionError – if
estimatoris not fitted or type info is missing from the graph