lenskit.util#
Miscellaneous utility functions.
Functions
|
|
|
Get the current memory use for this process |
|
Get the maximum memory use for this process |
Classes
|
- class lenskit.util.Stopwatch(start=True)#
Bases:
object
Timer class for recording elapsed wall time in operations.
- lenskit.util.derivable_rng(spec)#
RNGs that may be derivable from data in the query. These are for designs that need to be able to reproducibly derive RNGs for different keys, like user IDs (to make a “random” recommender produce the same sequence for the same user).
Seed specifications may be any of the following:
A seed (
SeedLike
).The value
'user'
, which will derive a seed from the query user ID.A tuple of the form
(seed, 'user')
, that will useseed
as the basis and drive from it a new seed based on the user ID.
See also
- Parameters:
spec (int | integer[Any] | Sequence[int] | SeedSequence | Literal['user'] | tuple[int | ~numpy.integer[~typing.Any] | ~typing.Sequence[int] | ~numpy.random.bit_generator.SeedSequence, ~typing.Literal['user']] | None) – The seed specification.
- Returns:
A function taking one (or more) key values, like
derive_seed()
, and returning a random number generator.- Return type:
function
- lenskit.util.random_generator(seed=None)#
Create a a random generator with the given seed, falling back to a global generator if no seed is provided. If no global generator has been configured with
set_global_rng()
, it returns a fresh random RNG.- Parameters:
seed (int | integer[Any] | Sequence[int] | SeedSequence | Generator | BitGenerator | None)
- Return type:
- lenskit.util.set_global_rng(seed)#
Set the global default RNG.
- Parameters:
seed (int | integer[Any] | Sequence[int] | SeedSequence | Generator | BitGenerator | None)
Modules