Class CentroidCBRecommender<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.contentbased.CentroidCBRecommender<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 CentroidCBRecommender<U> extends UserFastRankingRecommender<U>
Content-based recommendation algorithm, based on a tf-idf scheme. Each piece of content published by
a single user is considered as taken as a single content. Then, using some of these contents, a
centroid using the tf-idf weights is computed for each user.
Finally, the recommendation score of a link is just the cosine similarity between the vectors of two
separate users.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<U,java.util.Map<java.lang.String,java.lang.Double>>
centroids
The centroids of the users.private java.util.Map<java.lang.String,java.util.Map<U,java.lang.Double>>
invCentroids
Inverse index for the centroids.private java.util.Map<U,java.lang.Double>
modules
Modules of the centroids.Fields inherited from class es.uam.eps.ir.relison.links.recommendation.UserFastRankingRecommender
graph
-
Constructor Summary
Constructors Constructor Description CentroidCBRecommender(FastGraph<U> graph, WrapperIndividualForwardContentIndex<?,U> index)
Constructor.CentroidCBRecommender(FastGraph<U> graph, WrapperIndividualForwardContentIndex<?,U> index, EdgeOrientation orient)
Constructor. -
Method Summary
Modifier and Type Method Description private void
createTerm(java.lang.String term)
Add a term to the inverse centroid.it.unimi.dsi.fastutil.ints.Int2DoubleMap
getScoresMap(int uIdx)
Methods inherited from class es.uam.eps.ir.relison.links.recommendation.UserFastRankingRecommender
getFreq, getFreq, getGraph
Methods inherited from class es.uam.eps.ir.ranksys.rec.fast.FastRankingRecommender
getRecommendation
Methods inherited from class es.uam.eps.ir.ranksys.rec.fast.AbstractFastRecommender
getRecommendation, getRecommendation, getRecommendation, getRecommendation, getRecommendation, getRecommendation, getRecommendation, iidx2item, item2iidx, numItems, numUsers, uidx2user, user2uidx
Methods inherited from class es.uam.eps.ir.ranksys.rec.AbstractRecommender
getRecommendation, getRecommendation
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface es.uam.eps.ir.ranksys.fast.index.FastItemIndex
containsItem, getAllIidx, getAllItems, iidx2item, iidx2item, item2iidx, item2iidx
-
Field Details
-
centroids
The centroids of the users. -
invCentroids
Inverse index for the centroids. -
modules
Modules of the centroids.
-
-
Constructor Details
-
CentroidCBRecommender
Constructor. This variant just takes the information pieces published by each user to generate his/her centroid.- Parameters:
graph
- The training graph.index
- Content index that contains information about users.
-
CentroidCBRecommender
public CentroidCBRecommender(FastGraph<U> graph, WrapperIndividualForwardContentIndex<?,U> index, EdgeOrientation orient)Constructor. This variant takes the contents published by the neighbors of a user to generate the centroids.- Parameters:
graph
- the training graph.index
- content index that contains information about users.orient
- the orientation for selecting the neighbors.
-
-
Method Details
-
createTerm
private void createTerm(java.lang.String term)Add a term to the inverse centroid.- Parameters:
term
- the term.
-
getScoresMap
public it.unimi.dsi.fastutil.ints.Int2DoubleMap getScoresMap(int uIdx)
-