lenskit.util#
Miscellaneous utility functions.
Functions
|
Decorator for property getters to cache the property value. |
|
|
|
Clone an algorithm, but not its fitted data. |
|
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)#
Get a derivable RNG, for use cases where the code needs to be able to reproducibly derive sub-RNGs for different keys, such as user IDs.
- Parameters:
spec –
Any value supported by the seed parameter of
seedbank.numpy_rng()
, in addition to the following values:the string
'user'
a tuple of the form (
seed
,'user'
)
Either of these forms will cause the returned function to re-derive new RNGs.
- Returns:
A function taking one (or more) key values, like
derive_seed()
, and returning a random number generator.- Return type:
function
- lenskit.util.clone(algo)#
Clone an algorithm, but not its fitted data. This is like
sklearn.base.clone()
, but may not work on arbitrary SciKit estimators. LensKit algorithms are compatible with SciKit clone, however, so feel free to use that if you need more general capabilities.This function is somewhat derived from the SciKit one.
>>> from lenskit.algorithms.bias import Bias >>> orig = Bias() >>> copy = clone(orig) >>> copy is orig False >>> copy.damping == orig.damping True
- Parameters:
algo (A)
- Return type:
A
Modules