Class UpdateableGraphCosineSimilarity
java.lang.Object
es.uam.eps.ir.relison.links.recommendation.algorithms.knn.similarities.GraphSimilarity
es.uam.eps.ir.relison.links.recommendation.updateable.knn.sim.UpdateableGraphSimilarity
es.uam.eps.ir.relison.links.recommendation.updateable.knn.sim.UpdateableGraphCosineSimilarity
- All Implemented Interfaces:
es.uam.eps.ir.ranksys.nn.sim.Similarity
,UpdateableSimilarity
public class UpdateableGraphCosineSimilarity extends UpdateableGraphSimilarity
Updateable version of the cosine similarity.
-
Field Summary
Fields Modifier and Type Field Description private it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap
norm2map
A map for storing the norms.Fields inherited from class es.uam.eps.ir.relison.links.recommendation.algorithms.knn.similarities.GraphSimilarity
graph
-
Constructor Summary
Constructors Constructor Description UpdateableGraphCosineSimilarity(FastGraph<?> graph)
Constructor. -
Method Summary
Modifier and Type Method Description java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2id>
similarElems(int uidx)
java.util.function.IntToDoubleFunction
similarity(int uidx)
it.unimi.dsi.fastutil.ints.IntList
updateAdd(int idx1, int idx2, double val)
Updates the similarities between user/items after adding/modifying a rating.void
updateAddElement()
Updates the similarities between users/items after adding a new element.void
updateDel(int idx1, int idx2)
Updates the similarities between users/items after removing a rating.
-
Field Details
-
norm2map
private final it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap norm2mapA map for storing the norms.
-
-
Constructor Details
-
UpdateableGraphCosineSimilarity
Constructor.- Parameters:
graph
- the social network graph.
-
-
Method Details
-
updateAdd
public it.unimi.dsi.fastutil.ints.IntList updateAdd(int idx1, int idx2, double val)Description copied from interface:UpdateableSimilarity
Updates the similarities between user/items after adding/modifying a rating.- Parameters:
idx1
- index of useridx2
- index of itemval
- rating value- Returns:
- a pair which contains a) a list of users which have been fully updated b) a list of other updated similarities.
-
updateDel
public void updateDel(int idx1, int idx2)Description copied from interface:UpdateableSimilarity
Updates the similarities between users/items after removing a rating.- Parameters:
idx1
- index of useridx2
- index of item
-
updateAddElement
public void updateAddElement()Description copied from interface:UpdateableSimilarity
Updates the similarities between users/items after adding a new element. -
similarity
public java.util.function.IntToDoubleFunction similarity(int uidx) -
similarElems
public java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2id> similarElems(int uidx)
-