lenskit.splitting.holdout#
Per-user rating holdout methods for user-based data splitting.
Classes
|
Holdout methods select test rows for a user (or occasionally an item). |
|
Select a fraction of test rows per user/item. |
|
Select a fixed number of test rows per user/item, based on ordering by a field. |
|
Randomly select a fraction of test rows per user/item. |
|
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:
n (int) – the number of test items to select
rng – the random number generator or seed
rng_spec (SeedSequence | int | integer[Any] | ndarray[Any, dtype[Any]] | bytes | memoryview | str | Generator | RandomState | None)
- class lenskit.splitting.holdout.SampleFrac(frac, rng_spec=None)#
Bases:
HoldoutMethod
Randomly select a fraction of test rows per user/item.
- Parameters:
frac (float) – the fraction items to select for testing.
rng_spec (SeedSequence | int | integer[Any] | ndarray[Any, dtype[Any]] | bytes | memoryview | str | Generator | RandomState | None)
- 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.
- 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)