Sampling

Module containing functions for negative item sampling.

spotlight.sampling.sample_items(num_items, shape, random_state=None)[source]

Randomly sample a number of items.

Parameters:
  • num_items (int) – Total number of items from which we should sample: the maximum value of a sampled item id will be smaller than this.
  • shape (int or tuple of ints) – Shape of the sampled array.
  • random_state (np.random.RandomState instance, optional) – Random state to use for sampling.
Returns:

items – Sampled item ids.

Return type:

np.array of shape [shape]