lenskit.splitting.sample_users#

lenskit.splitting.sample_users(data: Dataset, size: int, method: HoldoutMethod, *, repeats: int, disjoint: bool = True, test_only: bool = False, rng: RNGInput = None) Iterator[TTSplit]#
lenskit.splitting.sample_users(data: Dataset, size: int, method: HoldoutMethod, *, disjoint: bool = True, rng: RNGInput = None, test_only: bool = False, repeats: None = None) TTSplit

Create train-test splits by sampling users. When repeats is None, returns a single train-test split; otherwise, it returns an iterator over multiple splits. If repeats=1, this function returns an iterator that yields a single train-test pair.

Parameters:
  • data – Data frame containing ratings or other data you wish to partition.

  • size – The sample size.

  • method – The method for obtaining user test ratings.

  • repeats – The number of samples to produce.

  • test_only – If True, returns splits with empty training sets (useful when you just want to save the test data).

  • rng – The random number generator or seed (see Random Seeds).

Returns:

The train-test pair(s).