# tfrs.examples.movielens.sample_listwise

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/recommenders/blob/v0.7.7/tensorflow_recommenders/examples/movielens.py#L129-L192) |

Function for converting the MovieLens 100K dataset to a listwise dataset.

    tfrs.examples.movielens.sample_listwise(
        rating_dataset: tf.data.Dataset,
        num_list_per_user: int = 10,
        num_examples_per_list: int = 10,
        seed: Optional[int] = None
    ) -> tf.data.Dataset

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Listwise ranking](https://www.tensorflow.org/recommenders/examples/listwise_ranking) |

<br />

<br />

<br />

| ## Args ||
|---|---|
| `rating_dataset` | The MovieLens ratings dataset loaded from TFDS with features "movie_title", "user_id", and "user_rating". |
| `num_list_per_user` | An integer representing the number of lists that should be sampled for each user in the training dataset. |
| `num_examples_per_list` | An integer representing the number of movies to be sampled for each list from the list of movies rated by the user. |
| `seed` | An integer for creating `np.random.RandomState`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tf.data.Dataset containing list examples. <br /> Each example contains three keys: "user_id", "movie_title", and "user_rating". "user_id" maps to a string tensor that represents the user id for the example. "movie_title" maps to a tensor of shape \[sum(num_example_per_list)\] with dtype tf.string. It represents the list of candidate movie ids. "user_rating" maps to a tensor of shape \[sum(num_example_per_list)\] with dtype tf.float32. It represents the rating of each movie in the candidate list. ||

<br />