recommender

The GraphLab Create recommender toolkit provides a unified interface to train a variety of recommender models and use them to make recommendations.

Recommender models can be created using graphlab.recommender.create() or loaded from a previously saved model using graphlab.load_model(). The input data must be an SFrame with a column containing user ids, a column containing item ids, and optionally a column containing target values such as movie ratings, etc. When a target is not provided (as is the case in implicit feedback settings), then a collaborative filtering model based on item-item similarity is returned. For more details, please see the documentation for graphlab.recommender.create().

A recommender model object can perform key tasks including predict, recommend, evaluate, and save. Model attributes and statistics may be obtained via m.get(), where m is a model object. In particular, trained model parameters may be accessed using m.get(‘coefficients’) or equivalently m[‘coefficients’]. For more details, please see individual model API documentation below.

In addition to the API documentation, please see the data science Gallery, How-tos, and the recommender systems chapter of the User Guide for more details and extended examples.

>>> sf = graphlab.SFrame({'user_id': ["0", "0", "0", "1", "1", "2", "2", "2"],
...                       'item_id': ["a", "b", "c", "a", "b", "b", "c", "d"],
...                       'rating': [1, 3, 2, 5, 4, 1, 4, 3]})
>>> m = graphlab.recommender.create(sf, target='rating')
>>> recs = m.recommend()
>>> print recs
+---------+---------+---------------+------+
| user_id | item_id |     score     | rank |
+---------+---------+---------------+------+
|    0    |    d    | 2.42301885789 |  1   |
|    1    |    c    | 5.52301720893 |  1   |
|    1    |    d    | 5.20882169849 |  2   |
|    2    |    a    |  2.149379798  |  1   |
+---------+---------+---------------+------+
[4 rows x 4 columns]

>>> m['coefficients']
{'intercept': 3.1321961361684068, 'item_id': Columns:
  item_id str
  linear_terms  float
  factors array

 Rows: 4

 Data:
 +---------+-----------------+--------------------------------+
 | item_id |   linear_terms  |            factors             |
 +---------+-----------------+--------------------------------+
 |    a    | -0.381912890376 | array('d', [0.006779233276 ... |
 |    b    | -0.482275197699 | array('d', [-3.57188659440 ... |
 |    c    |  0.664901063905 | array('d', [-0.00025265078 ... |
 |    d    |  0.352987048665 | array('d', [-0.00197509767 ... |
 +---------+-----------------+--------------------------------+
 [4 rows x 3 columns], 'user_id': Columns:
  user_id str
  linear_terms  float
  factors array

 Rows: 3

 Data:
 +---------+-----------------+--------------------------------+
 | user_id |   linear_terms  |            factors             |
 +---------+-----------------+--------------------------------+
 |    0    |  -1.06188402031 | array('d', [-0.00321943390 ... |
 |    1    |  1.72356956865  | array('d', [0.005337682218 ... |
 |    2    | -0.604970370745 | array('d', [-0.00274082382 ... |
 +---------+-----------------+--------------------------------+
 [3 rows x 3 columns]}

creating a recommender

create A unified interface for training recommender models.
util.RecommenderViews

item similarity models

item_similarity_recommender.create Create a recommender that uses item-item similarities based on users in common.
item_similarity_recommender.get_default_options Get the default options for the toolkit ItemSimilarityRecommender.
item_similarity_recommender.ItemSimilarityRecommender A model that ranks an item according to its similarity to other items observed for the user in question.

item content recommenders

item_content_recommender.create Create a content-based recommender model in which the similarity between the items recommended is determined by the content of those items rather than learned from user interaction data.
item_content_recommender.get_default_options Get the default options for the toolkit ItemContentRecommender.
item_content_recommender.ItemContentRecommender A recommender based on the similarity between item content rather using user interaction patterns to compute similarity.

factorization recommenders

factorization_recommender.create Create a FactorizationRecommender that learns latent factors for each user and item and uses them to make rating predictions.
factorization_recommender.get_default_options Get the default options for the toolkit FactorizationRecommender.
factorization_recommender.FactorizationRecommender A FactorizationRecommender learns latent factors for each user and item and uses them to make rating predictions.

factorization recommenders for ranking

ranking_factorization_recommender.create Create a RankingFactorizationRecommender that learns latent factors for each user and item and uses them to make rating predictions.
ranking_factorization_recommender.get_default_options Get the default options for the toolkit RankingFactorizationRecommender.
ranking_factorization_recommender.RankingFactorizationRecommender A RankingFactorizationRecommender learns latent factors for each user and item and uses them to rank recommended items according to the likelihood of observing those (user, item) pairs.

popularity-based recommenders

popularity_recommender.create Create a model that makes recommendations using item popularity.
popularity_recommender.get_default_options Get the default options for the toolkit PopularityRecommender.
popularity_recommender.PopularityRecommender The Popularity Model ranks an item according to its overall popularity.

utilities

util.compare_models Compare the prediction or recommendation performance of recommender models on a common test dataset.
util.random_split_by_user Create a recommender-friendly train-test split of the provided data set.
util.precision_recall_by_user Compute precision and recall at a given cutoff for each user.