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
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 .
|
Returns |
A tf.data.Dataset containing list examples.
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.
|