module onnxrt.ops_cpu.op_label_encoder#

Inheritance diagram of mlprodict.onnxrt.ops_cpu.op_label_encoder

Short summary#

module mlprodict.onnxrt.ops_cpu.op_label_encoder

Runtime operator.

source on GitHub

Classes#

class

truncated documentation

LabelEncoder

LabelEncoder (ai.onnx.ml) ========================= Maps each element in the input tensor to another value. The mapping …

Properties#

property

truncated documentation

args_default

Returns the list of arguments as well as the list of parameters with the default values (close to the signature). …

args_default_modified

Returns the list of modified parameters.

args_mandatory

Returns the list of optional arguments.

args_optional

Returns the list of optional arguments.

atts_value

Returns all parameters in a dictionary.

Methods#

method

truncated documentation

__init__

_run

Documentation#

Runtime operator.

source on GitHub

class mlprodict.onnxrt.ops_cpu.op_label_encoder.LabelEncoder(ai.onnx.ml)#

Bases: OpRun


Maps each element in the input tensor to another value.

The mapping is determined by the two parallel attributes, ‘keys_*’ and ‘values_*’ attribute. The i-th value in the specified ‘keys_*’ attribute would be mapped to the i-th value in the specified ‘values_*’ attribute. It implies that input’s element type and the element type of the specified ‘keys_*’ should be identical while the output type is identical to the specified ‘values_*’ attribute. If an input element can not be found in the specified ‘keys_*’ attribute, the ‘default_*’ that matches the specified ‘values_*’ attribute may be used as its output value.

Let’s consider an example which maps a string tensor to an integer tensor. Assume and ‘keys_strings’ is [“Amy”, “Sally”], ‘values_int64s’ is [5, 6], and ‘default_int64’ is ‘-1’. The input [“Dori”, “Amy”, “Amy”, “Sally”, “Sally”] would be mapped to [-1, 5, 5, 6, 6].

Since this operator is an one-to-one mapping, its input and output shapes are the same. Notice that only one of ‘keys_*’/’values_*’ can be set.

For key look-up, bit-wise comparison is used so even a float NaN can be mapped to a value in ‘values_*’ attribute.

Attributes

  • default_float: A float. Default value is namedefaultfloatf-0.0typeFLOAT (FLOAT)

  • default_int64: An integer. Default value is namedefaultint64i-1typeINT (INT)

  • default_string: A string. Default value is namedefaultstringsUnusedtypeSTRING (STRING)

  • keys_floats: A list of floats. default value cannot be automatically retrieved (FLOATS)

  • keys_int64s: A list of ints. default value cannot be automatically retrieved (INTS)

  • keys_strings: A list of strings. One and only one of ‘keys_*’s should be set. default value cannot be automatically retrieved (STRINGS)

  • values_floats: A list of floats. default value cannot be automatically retrieved (FLOATS)

  • values_int64s: A list of ints. default value cannot be automatically retrieved (INTS)

  • values_strings: A list of strings. One and only one of ‘value_*’s should be set. default value cannot be automatically retrieved (STRINGS)

Inputs

  • X (heterogeneous)T1: Input data. It can be either tensor or scalar.

Outputs

  • Y (heterogeneous)T2: Output data.

Type Constraints

  • T1 tensor(string), tensor(int64), tensor(float): The input type is a tensor of any shape.

  • T2 tensor(string), tensor(int64), tensor(float): Output type is determined by the specified ‘values_*’ attribute.

Version

Onnx name: LabelEncoder

This version of the operator has been available since version 2 of domain ai.onnx.ml.

Runtime implementation: LabelEncoder

__init__(onnx_node, desc=None, **options)#
_run(x, attributes=None, verbose=0, fLOG=None)#

Should be overwritten.

source on GitHub