def compute_similarity_weight(num_contacts: int, max_val: float=2.0, k: float=1.0) -> float:
"""
Compute the similarity weighting factor based on the number of user-item interactions.
Args:
num_contacts (int): Number of user-item interactions.
max_val (float): Maximum value for the similarity weighting factor.
k (float): Scaling factor that controls the rate of increase of the similarity weighting factor.
Returns:
float: Similarity weighting factor between 0 and 2.
The factor approaches 2 as the number of contacts increases.
0 if there are no contacts, 1 if there is one contact, and close to 2 if there are many contacts by default.
"""
return max_val * num_contacts / (num_contacts + k)
Last active
June 18, 2025 14:20
-
-
Save myui/ff4426f011ff4edf010c0c86daab04f5 to your computer and use it in GitHub Desktop.
Author
myui
commented
Jun 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment