lenskit.stochastic.StochasticTopNConfig#

class lenskit.stochastic.StochasticTopNConfig#

Configuration for StochasticTopNRanker.

n: int | None = None#

The number of items to select. -1 or None to return all scored items.

rng: lenskit.random.DerivableSeed = None#

Random number generator configuration.

transform: Literal['softmax', 'linear'] | None = 'softmax'#

Transformation to convert scores into ranking probabilities.

softmax

Use the softmax of the item scores as the selection probabilities.

linear

Linearly re-scale item scores to be selection probabilities. This equivalent to min-max scaling the scores, then re-scaling to sum to 1.

None

No transformation, except negative scores are clamped to (almost) zero. Not recommended unless your item scorer emits multinomial probabilities.

scale: float = 1.0#

Scalar multiplier to apply to scores prior to transformation. This is equivalent to the \(\beta\) parameter for parameterized softmax transformation. Larger values will decrease the entropy of the sampled rankings.