Class LocalGreedyReranker<U,I>
java.lang.Object
es.uam.eps.ir.relison.links.recommendation.reranking.global.local.LocalReranker<U,I>
es.uam.eps.ir.relison.links.recommendation.reranking.global.local.LocalGreedyReranker<U,I>
- Type Parameters:
U- type of the users.I- type of the items.
- All Implemented Interfaces:
GlobalReranker<U,I>
- Direct Known Subclasses:
LocalLambdaReranker
public abstract class LocalGreedyReranker<U,I> extends LocalReranker<U,I>
Generalization of greedy local reranking strategies, for processing several recommendations at a time.
These rerankers, given a set of recommendations, sequentially process them one by one. Those
recommendations which are processed later are aware of the previously processed recommendations.
-
Field Summary
Fields Modifier and Type Field Description protected intcutOffMaximum length of the rankings -
Constructor Summary
Constructors Constructor Description LocalGreedyReranker(int cutOff)Constructor.LocalGreedyReranker(int cutOff, int seed)Constructor -
Method Summary
Modifier and Type Method Description protected static int[]getBasePerm(int n)Gets the base permutation (the i-th element remains at the i-th position)private es.uam.eps.ir.ranksys.core.Recommendation<U,I>permuteRecommendation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int[] perm)Given a recommendation and a permutation, builds a new recommendation with the changed order.protected int[]rerankPermutation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int maxLength)Given a recommendation, permutates it according to the given criteriaprotected es.uam.eps.ir.ranksys.core.Recommendation<U,I>rerankRecommendation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int maxLength)Given a recommendation, reranks it.protected intselectItem(U u, it.unimi.dsi.fastutil.ints.IntSortedSet remainingI, java.util.List<org.ranksys.core.util.tuples.Tuple2od<I>> list)Selects the next item to add in the permutationprotected abstract voidupdate(U user, org.ranksys.core.util.tuples.Tuple2od<I> bestItemValue)Given a user, and the next value to add, updates the reranker parameters.protected abstract doublevalue(org.ranksys.core.util.tuples.Tuple2od<I> get)Computes the value for an itemMethods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.local.LocalReranker
rerankRecommendations, update
-
Field Details
-
cutOff
protected final int cutOffMaximum length of the rankings
-
-
Constructor Details
-
LocalGreedyReranker
public LocalGreedyReranker(int cutOff)Constructor.- Parameters:
cutOff- the maximum length of the definitive rankings
-
LocalGreedyReranker
public LocalGreedyReranker(int cutOff, int seed)Constructor- Parameters:
cutOff- the maximum length of the definitive rankingsseed- random seed.
-
-
Method Details
-
rerankRecommendation
protected es.uam.eps.ir.ranksys.core.Recommendation<U,I> rerankRecommendation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int maxLength)Description copied from class:LocalRerankerGiven a recommendation, reranks it.- Specified by:
rerankRecommendationin classLocalReranker<U,I>- Parameters:
rec- the recommendation to rerank.maxLength- number of items to take from the original recommendation.- Returns:
- the updated recommendation.
-
rerankPermutation
protected int[] rerankPermutation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int maxLength)Given a recommendation, permutates it according to the given criteria- Parameters:
rec- original recommendationmaxLength- the maximum length of the definitive rankings- Returns:
- the permutation
-
permuteRecommendation
private es.uam.eps.ir.ranksys.core.Recommendation<U,I> permuteRecommendation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int[] perm)Given a recommendation and a permutation, builds a new recommendation with the changed order.- Parameters:
rec- the original recommendation.perm- the permutation.- Returns:
- the permuted recommendation.
-
getBasePerm
protected static int[] getBasePerm(int n)Gets the base permutation (the i-th element remains at the i-th position)- Parameters:
n- the size of the base permutation- Returns:
- the permutation.
-
selectItem
protected int selectItem(U u, it.unimi.dsi.fastutil.ints.IntSortedSet remainingI, java.util.List<org.ranksys.core.util.tuples.Tuple2od<I>> list)Selects the next item to add in the permutation- Parameters:
u- the user.remainingI- remaining items for user ulist- the list of scored items.- Returns:
- the next item.
-
update
Given a user, and the next value to add, updates the reranker parameters.- Parameters:
user- The userbestItemValue- The next value to add at the ranking
-
value
Computes the value for an item- Parameters:
get- The item, along its original value.- Returns:
- the value.
-