Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RP3Beta #634

Open
wants to merge 1 commit into
base: 0.2.x
Choose a base branch
from
Open

Add RP3Beta #634

wants to merge 1 commit into from

Conversation

deklanw
Copy link
Contributor

@deklanw deklanw commented Dec 29, 2020

Random walk method from Updatable, Accurate, Diverse, and Scalable Recommendations for Interactive Applications https://dl.acm.org/doi/10.1145/2955101

specific_user_transitions = self.user_transition[user]

# make all item predictions for specified users
user_all_items = specific_user_transitions @ self.item_transition @ self.user_transition @ self.item_degree_inv.power(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the whole user_all_items matrix can be computed in advance to avoid multiplication in each batch.

Copy link
Contributor Author

@deklanw deklanw Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linzihan-backforward Hello, sorry for the (very) late reply. I intentionally avoided computing the entire user_item matrix to save memory. I included the all-at-once implementation at the top for reference, and explained the former. See

# for reference, doing it in one computation
# since the resultant matrix is dense, I'll refrain from doing this
def calculate_rp3beta(B, beta):
user_degree_inv = get_inv_degree_matrix(B)
item_degree_inv = get_inv_degree_matrix(B.T)
# multiplication on left for row-wise scaling
user_transition = user_degree_inv @ B
item_transition = item_degree_inv @ B.T
P3 = user_transition @ item_transition @ user_transition
# multiplication on right for column-wise scaling (i.e., we're reweighting by inverse item popularity to a power)
RP3Beta = P3 @ item_degree_inv.power(beta)
return RP3Beta

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It make sense. We will test the algorithm as soon as possible. It will be merged into the future version if everything is OK. Thanks again for your contribution !


specific_user_transitions = self.user_transition[user]

item_predictions = specific_user_transitions @ self.item_transition @ self.user_transition @ self.item_degree_inv.power(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants