# tfdv.experimental_get_feature_value_slicer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/data-validation/blob/v1.16.1/tensorflow_data_validation/utils/slicing_util.py#L57-L207) |

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

    tfdv.experimental_get_feature_value_slicer(
        features: Dict[types.FeatureName, Optional[_ValueType]]
    ) -> types.SliceFunction

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\]})

<br />

<br />

<br />

| ## Args ||
|---|---|
| `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. |

<br />

<br />

<br />

<br />

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

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `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`. |

<br />