turicreate.recommender.ranking_factorization_recommender.RankingFactorizationRecommender.get_similar_items

RankingFactorizationRecommender.get_similar_items(items=None, k=10, verbose=False)

Get the k most similar items for each item in items.

Each type of recommender has its own model for the similarity between items. For example, the item_similarity_recommender will return the most similar items according to the user-chosen similarity; the factorization_recommender will return the nearest items based on the cosine similarity between latent item factors.

Parameters:
items : SArray or list; optional

An SArray or list of item ids for which to get similar items. If ‘None’, then return the k most similar items for all items in the training set.

k : int, optional

The number of similar items for each item.

verbose : bool, optional

Progress printing is shown.

Returns:
out : SFrame

A SFrame with the top ranked similar items for each item. The columns item, ‘similar’, ‘score’ and ‘rank’, where item matches the item column name specified at training time. The ‘rank’ is between 1 and k and ‘score’ gives the similarity score of that item. The value of the score depends on the method used for computing item similarities.

Examples

>>> sf = turicreate.SFrame({'user_id': ["0", "0", "0", "1", "1", "2", "2", "2"],
                          'item_id': ["a", "b", "c", "a", "b", "b", "c", "d"]})
>>> m = turicreate.item_similarity_recommender.create(sf)
>>> nn = m.get_similar_items()