lenskit.splitting.crossfold_records#

lenskit.splitting.crossfold_records(data, partitions, *, test_only=False, rng=None)#

Partition a dataset by records into cross-fold partitions. This partitions the records (ratings, play counts, clicks, etc.) into k partitions without regard to users or items.

Since record-based random cross-validation doesn’t make much sense with repeated interactions, this splitter only supports operating on the dataset’s interaction matrix.

Parameters:
  • data (Dataset) – Ratings or other data you wish to partition.

  • partitions (int) – The number of partitions to produce.

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

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

Returns:

an iterator of train-test pairs

Return type:

iterator