tfma.utils.get_by_keys

Returns value with given key(s) in (possibly multi-level) dict.

The keys represent multiple levels of indirection into the data. For example if 3 keys are passed then the data is expected to be a dict of dict of dict. For compatibily with data that uses prefixing to create separate the keys in a single dict, lookups will also be searched for under the keys separated by '/'. For example, the keys 'head1' and 'probabilities' could be stored in a a single dict as 'head1/probabilties'.

data Dict to get value from.
keys Sequence of keys to lookup in data. None keys will be ignored.
default_value Default value if not found.
optional Whether the key is optional or not. If default value is None and optional is False then a ValueError will be raised if key not found.

ValueError If (non-optional) key is not found.