lenskit.splitting.SampleN#

class lenskit.splitting.SampleN(n, rng=None)#

Bases: HoldoutMethod

Randomly select a fixed number of test rows per user/item.

Stability:
Caller (see Stability Levels).
Parameters:
n: int#
rng: numpy.random.Generator#
__call__(items)#

Subset an item list (in the uncommon case of item-based holdouts, the item list actually holds user IDs).

Parameters:
Returns:

The list of test items.

Return type:

lenskit.data.ItemList