tfdv.experimental_get_feature_value_slicer

Returns a function that generates sliced record batches for a given one.

The returned function returns sliced record batches based on the combination of all features specified in features. To slice on features separately ( e.g., slice on age feature and separately slice on interests feature), you must use separate slice functions.

Examples:

Slice on each value of the specified features.

slice_fn = get_feature_value_slicer( features={'age': None, 'interests': None})

Slice on a specified feature value.

slice_fn = get_feature_value_slicer(features={'interests': ['dogs']})

Slice on each value of one feature and a specified value of another.

slice_fn = get_feature_value_slicer( features={'fruits': None, 'numbers': [1]})

features A mapping of features to an optional iterable of values that the returned function will slice on. If values is None for a feature, then the slice keys will reflect each distinct value found for that feature in the input record batch. If values are specified for a feature, then the slice keys will reflect only those values for the feature, if found in the input record batch. Values must be an iterable of strings or integers.

A function that takes as input a single record batch and returns a list of sliced record batches (slice_key, record_batch).

TypeError If feature values are not specified in an iterable.
NotImplementedError If a value of a type other than string or integer is specified in the values iterable in features.