DictVectorizer#
Domain:
ai.onnx.mlSince version: 1
Uses an index mapping to convert a dictionary to an array.
Given a dictionary, each key is looked up in the vocabulary attribute corresponding to
the key type. The index into the vocabulary array at which the key is found is then
used to index the output 1-D tensor ‘Y’ and insert into it the value found in the dictionary ‘X’.
The key type of the input map must correspond to the element type of the defined vocabulary attribute.
Therefore, the output array will be equal in length to the index mapping vector parameter.
All keys in the input dictionary must be present in the index mapping vector.
For each item in the input dictionary, insert its value in the output array.
Any keys not present in the input dictionary, will be zero in the output array.
For example: if the `string_vocabulary`` parameter is set to ``["a", "c", "b", "z"]`,
then an input of `{"a": 4, "c": 8}`` will produce an output of ``[4, 8, 0, 0]`.
Inputs
X (T1): A dictionary.
Outputs
Y (T2): A 1-D tensor holding values from the input dictionary.
Type Constraints
T1: The input must be a map from strings or integers to either strings or a numeric type. The key and value types cannot be the same. Allowed types: map(int64, double), map(int64, float), map(int64, string), map(string, double), map(string, float), map(string, int64).
T2: The output will be a tensor of the value type of the input map. It’s shape will be [1,C], where C is the length of the input dictionary. Allowed types: tensor(double), tensor(float), tensor(int64), tensor(string).
Examples#
test_cc_dict_vectorizer_int64_float
Node:
ai.onnx.ml.DictVectorizer(x) -> (y)
Attributes:
int64_vocabulary = [10, 20, 30]
Inputs:
x: shape=(2,), dtype=int64
[10, 30]
input_1: shape=(2,), dtype=float32
[1.5, 2.5]
Outputs:
y: shape=(3,), dtype=float32
[1.5, 0. , 2.5]
test_cc_dict_vectorizer_string_int64
Node:
ai.onnx.ml.DictVectorizer(x) -> (y)
Attributes:
string_vocabulary = ['a', 'c', 'b', 'z']
Inputs:
x: shape=(2,), dtype=object
['a', 'c']
input_1: shape=(2,), dtype=int64
[4, 8]
Outputs:
y: shape=(4,), dtype=int64
[4, 8, 0, 0]