lenskit.basic.topn#
Basic Top-N ranking.
Classes#
Configuration for top-N ranking. |
|
Rank scored items by their score and take the top N. The ranking length |
Module Contents#
- class lenskit.basic.topn.TopNConfig#
Bases:
pydantic.BaseModelConfiguration for top-N ranking.
- class lenskit.basic.topn.TopNRanker(config=None, **kwargs)#
Bases:
lenskit.pipeline.components.Component[lenskit.data.ItemList]Rank scored items by their score and take the top N. The ranking length can be passed either at runtime or at component instantiation time, with the latter taking precedence.
- Stability:
- Caller (see Stability Levels).
- Parameters:
config (object | None)
kwargs (Any)
- config: TopNConfig#
Configuration object.
- __call__(*, items, n=None)#
Rank the items.
- Parameters:
items (lenskit.data.ItemList) – The items to rank, with scores. Items with missing scores are not included in the final ranking.
n (int | None) – The number of items to return, or -1 to return all scored items. If
None, the length configured at construction time is used.
- Returns:
An ordered list of items, with scores and all other attributes preserved.
- Return type:
Exported Aliases#
- class lenskit.basic.topn.ItemList#
Re-exported alias for
lenskit.data.ItemList.
- class lenskit.basic.topn.Component#
Re-exported alias for
lenskit.pipeline.components.Component.