lenskit.splitting.holdout#

Per-user rating holdout methods for user-based data splitting.

Classes

HoldoutMethod(*args, **kwargs)

Holdout methods select test rows for a user (or occasionally an item).

LastFrac(frac[, field])

Select a fraction of test rows per user/item.

LastN(n[, field])

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

SampleFrac(frac[, rng_spec])

Randomly select a fraction of test rows per user/item.

SampleN(n[, rng_spec])

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

class lenskit.splitting.holdout.HoldoutMethod(*args, **kwargs)#

Bases: Protocol

Holdout methods select test rows for a user (or occasionally an item). Partition methods are callable; when called with a data frame, they return the test entries.

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

Bases: HoldoutMethod

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

Parameters:
class lenskit.splitting.holdout.SampleFrac(frac, rng_spec=None)#

Bases: HoldoutMethod

Randomly select a fraction of test rows per user/item.

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

Bases: HoldoutMethod

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

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

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

class lenskit.splitting.holdout.LastFrac(frac, field='timestamp')#

Bases: HoldoutMethod

Select a fraction of test rows per user/item.

Parameters:
  • frac (double) – the fraction of items to select for testing.

  • field (str)