user_item_knowledge_base
logger = logging.getLogger(__name__) module-attribute ¶
UserItemKnowledgeBase dataclass ¶
Unknown and known user/item base.
This class is used to store the status of the user and item base. The class stores the known and unknown user and item set. The class also provides methods to update the known and unknown user and item set.
Source code in src/recnexteval/evaluators/core/user_item_knowledge_base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
unknown_user = field(default_factory=set) class-attribute instance-attribute ¶
known_user = field(default_factory=set) class-attribute instance-attribute ¶
unknown_item = field(default_factory=set) class-attribute instance-attribute ¶
known_item = field(default_factory=set) class-attribute instance-attribute ¶
known_shape property ¶
Known number of user id and item id.
id are zero-indexed and the shape returns the max id + 1.
Note
max is used over len as there may be gaps in the id sequence and we are only concerned with the shape of the user-item interaction matrix.
Returns:
| Type | Description |
|---|---|
tuple[int, int] | Tuple of (|user|, |item|). |
global_shape property ¶
Global number of user id and item id.
This is the shape of the user-item interaction matrix considering all the users and items that has been possibly exposed. The global shape considers the fact that an unknown user/item can be exposed during the prediction stage when an unknown user/item id is requested for prediction on the algorithm.
Returns:
| Type | Description |
|---|---|
tuple[int, int] | Tuple of (|user|, |item|). |
update_known_user_item_base(data) ¶
Updates the known user and item set with the data.
Source code in src/recnexteval/evaluators/core/user_item_knowledge_base.py
58 59 60 61 | |
update_unknown_user_item_base(data) ¶
Updates the unknown user and item set with the data.
Source code in src/recnexteval/evaluators/core/user_item_knowledge_base.py
63 64 65 66 | |
reset_unknown_user_item_base() ¶
Clears the unknown user and item set.
Source code in src/recnexteval/evaluators/core/user_item_knowledge_base.py
68 69 70 71 | |