Class Cosine<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.foaf.Cosine<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 Cosine<U> extends UserFastRankingRecommender<U>
Recommender using the cosine similarity to produce recommendations. It considers each user as a vector, where the
i-th coordinate is the weight of the link between u and the i-th user, and takes the cosine between two user vectors
as the recommendation score.
Reference: Lü, L., Zhou. T. Link Prediction in Complex Networks: A survey. Physica A: Statistical Mechanics and its Applications, 390(6), March 2011, pp. 1150-1170.
-
Field Summary
Fields Modifier and Type Field Description private EdgeOrientationuSelNeighborhood selection for the target users.private java.util.Map<java.lang.Integer,java.lang.Double>uSizesMap containing the length of the neighborhoods of the target users.private EdgeOrientationvSelNeighborhood selection for the candidate users.private java.util.Map<java.lang.Integer,java.lang.Double>vSizesMap containing the length of the neighborhoods of the candidate users.Fields inherited from class es.uam.eps.ir.relison.links.recommendation.UserFastRankingRecommender
graph -
Constructor Summary
Constructors Constructor Description Cosine(FastGraph<U> graph, EdgeOrientation uSel, EdgeOrientation vSel)Constructor. -
Method Summary
Modifier and Type Method Description it.unimi.dsi.fastutil.ints.Int2DoubleMapgetScoresMap(int uidx)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
-
uSizes
private final java.util.Map<java.lang.Integer,java.lang.Double> uSizesMap containing the length of the neighborhoods of the target users. -
vSizes
private final java.util.Map<java.lang.Integer,java.lang.Double> vSizesMap containing the length of the neighborhoods of the candidate users. -
uSel
Neighborhood selection for the target users. -
vSel
Neighborhood selection for the candidate users.
-
-
Constructor Details
-
Cosine
Constructor.- Parameters:
graph- the graph.uSel- the neighborhood selection for the target user.vSel- the neighborhood selection for the candidate user.
-
-
Method Details
-
getScoresMap
public it.unimi.dsi.fastutil.ints.Int2DoubleMap getScoresMap(int uidx)
-