yobx.sklearn.category_encoders.polynomial_encoder#

yobx.sklearn.category_encoders.polynomial_encoder.category_encoders_polynomial_encoder(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: PolynomialEncoder, X: str, name: str = 'polynomial_encoder') str[source]#

Converts a category_encoders.PolynomialEncoder into ONNX.

The encoder replaces each categorical column with polynomial contrast coding columns. The number of output columns per categorical feature is n_categories - 1 (one column is dropped to avoid perfect multicollinearity). Non-categorical columns pass through unchanged.

X  ──col_j (categorical)──►  Equal(val_i)?──►  contrast_i_0
                              ...              contrast_i_1
                              IsNaN?──────────►  nan_contrast_0
                                                 nan_contrast_1
                              default──────────►  unknown_contrast_0
                                                  unknown_contrast_1

X  ──col_k (numerical)──►  unchanged

The conversion pre-computes a combined lookup table (original category value → contrast row) from the fitted ordinal_encoder and mapping attributes. Unknown categories and NaN inputs are handled via separate Where nodes that override the default value.

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

  • sts – shapes defined by scikit-learn

  • estimator – a fitted PolynomialEncoder

  • outputs – desired output names

  • X – input name (shape (N, F))

  • name – prefix name for the added nodes

Returns:

output name