lenskit.stochastic.StochasticTopNRanker#
- class lenskit.stochastic.StochasticTopNRanker(config=None, **kwargs)#
Bases:
lenskit.pipeline.Component[lenskit.data.ItemList]Stochastic top-N ranking with optional weight transformation.
This uses the exponential sampling method, a more efficient approximation of Plackett-Luce sampling than even the Gumbell trick, as documented by Tim Vieira. It expects a scored list of input items, and samples
nitems, with selection probabilities proportional to their scores. Scores can be optionally rescaled (inverse temperature) and transformed (e.g. softmax).Note
When no transformation is used, negative scores are still clamped to (approximately) zero.
- Stability:
- Caller (see Stability Levels).
- Parameters:
config (StochasticTopNConfig | None)
- config: StochasticTopNConfig#
Stochastic ranker configuration.
- __call__(items, query=None, n=None, *, include_weights=False)#
Run the pipeline’s operation and produce a result. This is the key method for components to implement.
- Parameters:
items (lenskit.data.ItemList)
query (lenskit.data.QueryInput | None)
n (int | None)
include_weights (bool)
- Return type: