org.lenskit.knn.user

## Interface UserSimilarity

• All Known Implementing Classes:
UserVectorSimilarity

@DefaultImplementation(value=UserVectorSimilarity.class)
public interface UserSimilarity

Compute the similarity between two users.

Since:
0.11
• ### Method Summary

All Methods
Modifier and Type Method and Description
boolean isSparse()
Query whether this similarity is sparse.
boolean isSymmetric()
Query whether this similarity is symmetric.
double similarity(long u1, Long2DoubleMap v1, long u2, Long2DoubleMap v2)
Compute the similarity between two users.
• ### Method Detail

• #### similarity

double similarity(long u1,
Long2DoubleMap v1,
long u2,
Long2DoubleMap v2)

Compute the similarity between two users.

Parameters:
u1 - The first user ID.
v1 - The first user vector.
u2 - The second user ID.
v2 - The second user vector.
Returns:
The similarity between the two users, in the range [0,1].
• #### isSparse

boolean isSparse()

Query whether this similarity is sparse.

Returns:
true if the similarity function is sparse.
See Also:
VectorSimilarity.isSparse()
• #### isSymmetric

boolean isSymmetric()

Query whether this similarity is symmetric.

Warning: At present, asymmetric similarity functions may not produce correct results. In practice, this is not a problem, as most similarity functions are symmetric. Watch issue 151 for updates on this issue.

Returns:
true if the similarity function is symmetric.
See Also:
VectorSimilarity.isSymmetric()
Skip navigation links