flurs.types.Event
- class flurs.types.Event(user, item, value=1.0, context=array([], dtype=float64))[source]
An event object that represents a single user-item interaction.
- Parameters
user (User) – A User instance.
item (Item) – An Item instance.
value (float, default=1.0) – A value representing the feedback.
1.0
in case of positive-only feedback, or 5-scale value for rating prediction, for example.context (numpy array, default=empty) – Vector-represented contextual information associated with an interaction. An element can be day of the week, time, weather, etc.
Methods
__init__
(user, item[, value, context])encode
([n_user, n_item, index, feature, ...])Encode an event to an input vector for feature-based recommenders.
- encode(n_user=None, n_item=None, index=True, feature=True, context=True, vertical=False)[source]
Encode an event to an input vector for feature-based recommenders.
- Parameters
n_user (int) – Number of users currently registered to a recommender.
n_item (int) – Number of items currently registered to a recommender.
index (bool, default=True) – Include onehot-encoded user/item index to an input vector.
feature (bool, default=True) – Include features associated with user and item.
context (bool, default=True) – Include event-specific contextual information to a vector.
vertical (bool, default=False) – Return as a transposed n-by-1 vertical vector.
- Returns
n-dimensional vector representing a user-item interaction. Size can be
(n, 1)
or(1, n)
, depending onvertical
parameter.- Return type
array