# tfr.keras.model.UnivariateScorer

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/ranking/blob/v0.5.3/tensorflow_ranking/python/keras/model.py#L713-L777) |

Interface for univariate scorer.

Inherits From: [`Scorer`](https://www.tensorflow.org/ranking/api_docs/python/tfr/keras/model/Scorer)

The `UnivariateScorer` class is an abstract class to implement `score` in
`ModelBuilder` in tfr.keras with a univariate scoring function.

To be implemented by subclasses:

- `_score_flattened()`: Contains the logic to do the univariate scoring on flattened context and example features.

Example subclass implementation:

    class SimpleUnivariateScorer(UnivariateScorer):

      def _score_flattened(self, context_features, example_features):
        x = tf.concat([tensor for tensor in example_features.values()], -1)
        return tf.keras.layers.Dense(1)(x)

## Methods

### `__call__`

[View source](https://github.com/tensorflow/ranking/blob/v0.5.3/tensorflow_ranking/python/keras/model.py#L755-L777)

    __call__(
        context_features: https://www.tensorflow.org/ranking/api_docs/python/tfr/keras/model/TensorDict,
        example_features: https://www.tensorflow.org/ranking/api_docs/python/tfr/keras/model/TensorDict,
        mask: tf.Tensor
    ) -> Union[tf.Tensor, https://www.tensorflow.org/ranking/api_docs/python/tfr/keras/model/TensorDict]

See `Scorer`.