dgllife.utils.one_hot_encoding¶
-
dgllife.utils.
one_hot_encoding
(x, allowable_set, encode_unknown=False)[source]¶ One-hot encoding.
- Parameters
- Returns
List of boolean values where at most one value is True. The list is of length
len(allowable_set)
ifencode_unknown=False
andlen(allowable_set) + 1
otherwise.- Return type
Examples
>>> from dgllife.utils import one_hot_encoding >>> one_hot_encoding('C', ['C', 'O']) [True, False] >>> one_hot_encoding('S', ['C', 'O']) [False, False] >>> one_hot_encoding('S', ['C', 'O'], encode_unknown=True) [False, False, True]