lenskit.basic.random#
Classes#
Randomly select items from a candidate list. |
Module Contents#
- class lenskit.basic.random.RandomConfig#
Bases:
pydantic.BaseModel- rng: lenskit.random.DerivableSeed = None#
Random number generator configuration.
- class lenskit.basic.random.RandomSelector(config=None, **kwargs)#
Bases:
lenskit.pipeline.Component[lenskit.data.ItemList]Randomly select items from a candidate list.
- Stability:
- Caller (see Stability Levels).
- Parameters:
n – The number of items to select, or
-1to randomly permute the items.rng – The random number generator or specification (see Random Seeds). This class supports derivable RNGs.
config (RandomConfig | None)
- config: RandomConfig#
The component configuration object. Component classes that support configuration must redefine this attribute with their specific configuration class type, which can be a Python dataclass or a Pydantic model class.
- __call__(items, query=None, n=None)#
- Parameters:
items (lenskit.data.ItemList) – The items from which to pick.
query (lenskit.data.QueryInput | None) – The recommendation query; optional, and only consulted when the RNG seed is user-dependent.
n (int | None) – The number of items to select, overriding the configured value.
- Return type:
Exported Aliases#
- class lenskit.basic.random.ItemList#
Re-exported alias for
lenskit.data.ItemList.
- lenskit.basic.random.QueryInput#
Re-exported alias for
lenskit.data.QueryInput.
- class lenskit.basic.random.RecQuery#
Re-exported alias for
lenskit.data.RecQuery.
- class lenskit.basic.random.Component#
Re-exported alias for
lenskit.pipeline.Component.
- lenskit.basic.random.DerivableSeed#
Re-exported alias for
lenskit.random.DerivableSeed.
- class lenskit.basic.random.RNGFactory#
Re-exported alias for
lenskit.random.RNGFactory.
- lenskit.basic.random.derivable_rng()#
Re-exported alias for
lenskit.random.derivable_rng().