@Shareable public class UserVectorSimilarity extends Object implements UserSimilarity, Serializable
UserSimilarity
that delegates to a vector similarity.Constructor and Description |
---|
UserVectorSimilarity(VectorSimilarity sim) |
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 i1,
SparseVector v1,
long i2,
SparseVector v2)
Compute the similarity between two users.
|
String |
toString() |
@Inject public UserVectorSimilarity(VectorSimilarity sim)
public double similarity(long i1, SparseVector v1, long i2, SparseVector v2)
UserSimilarity
similarity
in interface UserSimilarity
i1
- The first user ID.v1
- The first user vector.i2
- The second user ID.v2
- The second user vector.public boolean isSparse()
UserSimilarity
isSparse
in interface UserSimilarity
true
if the similarity function is sparse.VectorSimilarity.isSparse()
public boolean isSymmetric()
UserSimilarity
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.
isSymmetric
in interface UserSimilarity
true
if the similarity function is symmetric.VectorSimilarity.isSymmetric()