pkg_preference_model¶
User preference modeling component based on a PKG.
A personal knowledge graph (PKG), in this particular application context, is a knowledge graph that is used to store the preferences of a single individual to support the delivery of services that are customized to that individual.
The implementation of get_item_preference() and get_slot_value_preference() depends on the release of the PKG API. See: https://github.com/iai-group/UserSimCRS/issues/110
Classes¶
Initializes the preference model of a simulated user based on a PKG. |
Module Contents¶
- class pkg_preference_model.PKGPreferenceModel(domain: usersimcrs.core.simulation_domain.SimulationDomain, item_collection: usersimcrs.items.item_collection.ItemCollection, historical_ratings: usersimcrs.items.ratings.Ratings, historical_user_id: str = None)¶
Bases:
usersimcrs.user_modeling.preference_model.PreferenceModel
Initializes the preference model of a simulated user based on a PKG.
- Parameters:
domain – Domain.
item_collection – Item collection.
historical_ratings – Historical ratings.
historical_user_id (Optional) – If provided, the simulated user is based on this particular historical user; otherwise, it is based on a randomly sampled user. This is mostly added to make the class testable.
- get_item_preference(item_id: str) float ¶
Returns a preference for a given item.
- Parameters:
item_id – Item ID.
- Returns:
Item preference, which is in [-1,1].
- Raises:
ValueError – If the item does not exist in the collection.
- get_slot_value_preference(slot: str, value: str) float ¶
Returns a preference on a given slot-value pair.
- Parameters:
slot – Slot name (needs to exist in the domain).
value – Slot value.
- Returns:
Slot-value preference, which is in [-1,1].