turicreate.recommender.factorization_recommender.FactorizationRecommender.get_similar_users¶
-
FactorizationRecommender.
get_similar_users
(users=None, k=10)¶ Get the k most similar users for each entry in users.
Each type of recommender has its own model for the similarity between users. For example, the factorization_recommender will return the nearest users based on the cosine similarity between latent user factors. (This method is not currently available for item_similarity models.)
Parameters: - users : SArray or list; optional
An
SArray
or list of user ids for which to get similar users. If ‘None’, then return the k most similar users for all users in the training set.- k : int, optional
The number of neighbors to return for each user.
Returns: - out : SFrame
A SFrame with the top ranked similar users for each user. The columns user, ‘similar’, ‘score’ and ‘rank’, where user matches the user column name specified at training time. The ‘rank’ is between 1 and k and ‘score’ gives the similarity score of that user. The value of the score depends on the method used for computing user 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.factorization_recommender.create(sf) >>> nn = m.get_similar_users()