lenskit.splitting.LastN#

class lenskit.splitting.LastN(n, field='timestamp')#

Bases: HoldoutMethod

Select a fixed number of test rows per user/item, based on ordering by a field.

Stability:
Caller (see Stability Levels).
Parameters:
  • n (int) – The number of test items to select.

  • field (str) – The field to order by.

n: int#
field: str#
__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