SCool
SCool

Reputation: 3375

How to get recommended users for an item with a matrix factorization recommender system?

Any tutorial or guide I've seen is for recommending items to a user, but how can I recommend users for an item?

I am currently using the implicit library alternating least squares model.

I have trained the model, and have my item and user latent vectors:

# get sparse item user matrix
sparse_item_user = sparse.csr_matrix((data['median spend'].astype(float), (data['product_id'], data['user_id'])))


# get sparse user item matrix for recommending
sparse_user_item = sparse.csr_matrix((data['median spend'].astype(float), (data['user_id'], data['product_id'])))


# fit model
model_als.fit(sparse_item_user)


# get user and item latent factors
user_factors = model_als.user_factors
item_factors = model_als.item_factors


# recommend items to a user
model_als.recommend(user_id, sparse_user_item)

How can I get the reverse, i.e. recommend users for a particular item? The idea is to get a list of contacts to send a marketing email for a particular product e.g. Bananas.

Could I just multiply the latent factors back together, and check the Bananas row?

user_item_matrix_recombined = np.dot(model_als.user_factors,model_als.item_factors.T)

user_item_matrix_recombined[:,Banana_index]

This could be computationally expensive to calculate the whole matrix first, is there another way? There are no methods in the implicit library to do this.

Upvotes: 1

Views: 343

Answers (0)

Related Questions