Components
Basic Concepts
Columns
Names of columns are fixed. They are user_id, item_id, weight (numerical value of interaction’s importance), datetime (date and time of interaction), rank (rank of recommendation according to score) and score (numeric value estimating how good recommendation it is). Column names are fixed in order to not constantly require mapping of columns in data and their actual meaning. So you’ll need to rename your columns.
|
Fixed column names for tables that contain interactions and recommendations. |
Identifiers
Mappings of external identifiers of users or items to internal ones.
Recommendation systems always require to have a mapping between external item ids in data sources
and internal ids in interaction matrix. Managing such mapping requires a lot of diligence. RecTools does it for you.
Every user and item must have a unique id.
External ids may be any unique hashable values, internal - always integers from 0
to n_objects-1
.
Interactions
This table stores history of interactions between users and items. It carries the most importance. Interactions table might also contain column describing importance of an interaction. Also timestamp of interaction. If no such column is provided, all interactions are assumed to be of equal importance.
User Features
This table stores data about users. It might include age, gender or any other features which may prove to be important for a recommender model.
Item Features
This table stores data about items. It might include category, price or any other features which may prove to be important for a recommender model.
Hot, warm, cold
There is a concept of a temperature we’re using for users and items:
hot - the ones that are present in interactions used for training (they may or may not have features);
warm - the ones that are not in interactions, but have some features;
cold - the ones we don’t know anything about (they are not in interactions and don’t have any features).
All the models are able to generate recommendations for the hot users (items). But as for warm and cold ones, there may be all possible combinations (neither of them, only cold, only warm, both). The important thing is that if model is able to recommend for cold users (items), but not for warm ones (see table below), it is still able to recommend for warm ones, but they will be considered as cold (no personalisation should be expected).
All of the above concepts are combined in Dataset. Dataset is used to build recommendation models and infer recommendations.
Dataset
Details of RecTools Dataset
See the API documentation for further details on Dataset:
|
Container class for all data for a recommendation model. |
Storage for dense features. |
|
|
Mapping between external and internal object ids. |
Structure to store info about user-item interactions. |
|
Storage for sparse features. |
Models
Details of RecTools Models
Model |
Supports features |
Recommends for warm |
Recommends for cold |
---|---|---|---|
DSSMModel |
Yes |
Yes |
No |
EASEModel |
No |
No |
No |
ImplicitALSWrapperModel |
Yes |
No |
No |
ImplicitItemKNNWrapperModel |
No |
No |
No |
LightFMWrapperModel |
Yes |
Yes |
Yes |
PopularModel |
No |
No |
Yes |
PopularInCategoryModel |
No |
No |
Yes |
PureSVDModel |
No |
No |
No |
RandomModel |
No |
No |
Yes |
See the API documentation for further details on Models:
Wrapper for rectools.models.dssm.DSSM |
|
Embarrassingly Shallow Autoencoders for Sparse Data model. |
|
Wrapper for implicit.als.AlternatingLeastSquares with possibility to use explicit features and GPU support. |
|
|
Wrapper for implicit.nearest_neighbours.ItemItemRecommender and its successors. |
Wrapper for lightfm.LightFM. |
|
|
Model generating recommendations based on popularity of items. |
Model generating recommendations based on popularity of items. |
|
PureSVD matrix factorization model. |
|
Model generating random recommendations. |
What are you waiting for? Train and apply them!
Recommendation Table
Recommendation table contains recommendations for each user. It has a fixed set of columns, though they are different for i2i and u2i recommendations. Recommendation table can also be used for calculation of metrics.
Metrics
Details of RecTools Metrics
See the API documentation for further details on Dataset:
Ratio of correctly recommended items among all items. |
|
Average Recommendations Popularity metric. |
|
|
Fbeta score for k first recommendations. |
HitRate calculates the fraction of users for which the correct answer is included in the recommendation list. |
|
Intra-List Diversity metric. |
|
|
Mean Average Precision at k (MAP@k). |
Matthew correlation coefficient calculates correlation between actual and predicted classification. |
|
Mean Reciprocal Rank at k (MRR@k). |
|
Mean Inverse User Frequency metric. |
|
|
Normalized Discounted Cumulative Gain at k (NDCG@k). |
Base pairwise distance calculator class |
|
|
Class for computing Hamming distance between a pair of items. |
Ratio of relevant items among top-k recommended items. |
|
Ratio of relevant recommended items among all items user interacted with after recommendations were made. |
|
Serendipity metric. |
|
|
Class for computing Hamming distance between multiple pairs of elements represented in features matrix in sparse form. |
|
Calculate metrics. |
Oops, yeah, can’t forget about them.
Model selection
Details of RecTools Model selection
See the API documentation for further details on Model selection:
Splitter for cross-validation by leave-one-out / leave-k-out scheme (recent activity). |
|
Slitter for cross-validation by random. |
|
Base class to construct data splitters. |
|
Splitter for cross-validation by leave-time-out scheme. |
|
|
Run cross validation on multiple models with multiple metrics. |
Tools
Details of RecTools Tools
See the API documentation for further details on Tools:
Class implements item-to-item ANN recommender. |
|
Class implements user to item ANN recommender. |
Visuals
Details of RecTools Visuals
See the API documentation for further details on Visuals:
Jupyter widgets app for item-to-item recommendations visualization and models comparison. |
|
|
Jupyter widgets app for user-to-item recommendations visualization and models comparison. |