Class CentroidCosineSimilarity<U>
java.lang.Object
es.uam.eps.ir.ranksys.rec.AbstractRecommender<U,I>
es.uam.eps.ir.ranksys.rec.fast.AbstractFastRecommender<U,I>
es.uam.eps.ir.ranksys.rec.fast.FastRankingRecommender<U,U>
es.uam.eps.ir.relison.links.recommendation.UserFastRankingRecommender<U>
es.uam.eps.ir.relison.links.recommendation.algorithms.standalone.bipartite.BipartiteRecommender<U>
es.uam.eps.ir.relison.links.recommendation.algorithms.standalone.bipartite.CentroidCosineSimilarity<U>
- Type Parameters:
U- type of the users
- All Implemented Interfaces:
es.uam.eps.ir.ranksys.core.index.ItemIndex<U>,es.uam.eps.ir.ranksys.core.index.UserIndex<U>,es.uam.eps.ir.ranksys.fast.index.FastItemIndex<U>,es.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>,es.uam.eps.ir.ranksys.rec.fast.FastRecommender<U,U>,es.uam.eps.ir.ranksys.rec.Recommender<U,U>
public class CentroidCosineSimilarity<U> extends BipartiteRecommender<U>
Recommender. Builds a centroid for each user in the network, using the vectors of the
followed users. The score is then computed as the cosine similarity of those centroids.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<U,cern.colt.matrix.DoubleMatrix1D>authVectorsVectorial representation of the authorities.private java.util.Map<java.lang.Long,java.lang.Integer>hubIdxIdentifiers of the hubs.private java.util.Map<U,java.lang.Double>normVectorsNorms of the vectors.Fields inherited from class es.uam.eps.ir.relison.links.recommendation.algorithms.standalone.bipartite.BipartiteRecommender
authorities, bipartiteGraph, hubs, modeFields inherited from class es.uam.eps.ir.relison.links.recommendation.UserFastRankingRecommender
graph -
Constructor Summary
Constructors Constructor Description CentroidCosineSimilarity(FastGraph<U> graph)Constructor -
Method Summary
Modifier and Type Method Description private doublecomputeCentroid(long hub, cern.colt.matrix.DoubleMatrix1D centroid)Computes a centroid for a hubprivate doublecomputeVector(long auth, cern.colt.matrix.DoubleMatrix1D vector)Computes the vector for an authority.it.unimi.dsi.fastutil.ints.Int2DoubleMapgetScoresMap(int i)Methods inherited from class es.uam.eps.ir.relison.links.recommendation.UserFastRankingRecommender
getFreq, getFreq, getGraphMethods inherited from class es.uam.eps.ir.ranksys.rec.fast.FastRankingRecommender
getRecommendationMethods inherited from class es.uam.eps.ir.ranksys.rec.fast.AbstractFastRecommender
getRecommendation, getRecommendation, getRecommendation, getRecommendation, getRecommendation, getRecommendation, getRecommendation, iidx2item, item2iidx, numItems, numUsers, uidx2user, user2uidxMethods inherited from class es.uam.eps.ir.ranksys.rec.AbstractRecommender
getRecommendation, getRecommendationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface es.uam.eps.ir.ranksys.fast.index.FastItemIndex
containsItem, getAllIidx, getAllItems, iidx2item, iidx2item, item2iidx, item2iidx
-
Field Details
-
authVectors
Vectorial representation of the authorities. -
normVectors
Norms of the vectors. -
hubIdx
private final java.util.Map<java.lang.Long,java.lang.Integer> hubIdxIdentifiers of the hubs.
-
-
Constructor Details
-
CentroidCosineSimilarity
Constructor- Parameters:
graph- the graph.
-
-
Method Details
-
getScoresMap
public it.unimi.dsi.fastutil.ints.Int2DoubleMap getScoresMap(int i) -
computeVector
private double computeVector(long auth, cern.colt.matrix.DoubleMatrix1D vector)Computes the vector for an authority.- Parameters:
auth- The identifier of the authority.vector- The vector.- Returns:
- The norm of the vector (L2 norm)
-
computeCentroid
private double computeCentroid(long hub, cern.colt.matrix.DoubleMatrix1D centroid)Computes a centroid for a hub- Parameters:
hub- The identifier of the hub.centroid- The vector.- Returns:
- The norm of the vector (L2 norm).
-