Class GlobalRankingGreedyReranker<U,I>
java.lang.Object
es.uam.eps.ir.relison.links.recommendation.reranking.global.globalranking.GlobalRankingGreedyReranker<U,I>
- Type Parameters:
U
- type of the usersI
- type of the items
- All Implemented Interfaces:
GlobalReranker<U,I>
- Direct Known Subclasses:
GlobalRankingLambdaReranker
public abstract class GlobalRankingGreedyReranker<U,I> extends java.lang.Object implements GlobalReranker<U,I>
Implementation of a greedy reranking strategy for optimizing global properties of the system.
This reranker chooses the items which have a more significant impact on the global property to optimize.
Given a set of recommendations for different users, these rerankers iteratively choose the user-item
pair that maximizes a given objective function. A user can only be selected as long as the ranking
does not have enough items.
-
Field Summary
Fields Modifier and Type Field Description protected int
cutOff
The number of recommended items that are reranked for each user.private org.ranksys.core.util.tuples.Tuple2id
maxItemScore
Item that achieves the maximum score and its value.private double
maxScore
Maximum score of an item.private U
maxUser
User that achieves the maximum value. -
Constructor Summary
Constructors Constructor Description GlobalRankingGreedyReranker(int cutOff)
Constructor. -
Method Summary
Modifier and Type Method Description java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<U,I>>
rerankRecommendations(java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<U,I>> recommendation, int maxLength)
Reranks a set of recommendations.protected abstract double
score(U user, org.ranksys.core.util.tuples.Tuple2od<I> item)
Computes the score of a recommendation itemprotected Tuple2oo<U,org.ranksys.core.util.tuples.Tuple2id>
selectRecommendation(java.util.Map<U,java.util.List<org.ranksys.core.util.tuples.Tuple2od<I>>> remainingItems)
Selects the next recommendation to add to the reranked one.protected abstract void
update(U user, org.ranksys.core.util.tuples.Tuple2od<I> selectedItem)
Updates the value of the objective function after a selection.
-
Field Details
-
cutOff
protected final int cutOffThe number of recommended items that are reranked for each user. -
maxScore
private double maxScoreMaximum score of an item. -
maxUser
User that achieves the maximum value. -
maxItemScore
private org.ranksys.core.util.tuples.Tuple2id maxItemScoreItem that achieves the maximum score and its value.
-
-
Constructor Details
-
GlobalRankingGreedyReranker
public GlobalRankingGreedyReranker(int cutOff)Constructor.- Parameters:
cutOff
- the cutoff.
-
-
Method Details
-
rerankRecommendations
public java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<U,I>> rerankRecommendations(java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<U,I>> recommendation, int maxLength)Description copied from interface:GlobalReranker
Reranks a set of recommendations.- Specified by:
rerankRecommendations
in interfaceGlobalReranker<U,I>
- Parameters:
recommendation
- a stream containing all the recommendations to rerank.maxLength
- maximum length of the definitive ranking for each user.- Returns:
- a stream of recommendations containing the definitive rankings.
-
selectRecommendation
protected Tuple2oo<U,org.ranksys.core.util.tuples.Tuple2id> selectRecommendation(java.util.Map<U,java.util.List<org.ranksys.core.util.tuples.Tuple2od<I>>> remainingItems)Selects the next recommendation to add to the reranked one.- Parameters:
remainingItems
- the remaining items.- Returns:
- a tuple containing the recommendation to add.
-
score
Computes the score of a recommendation item- Parameters:
user
- the useritem
- the original value.- Returns:
- the new score.
-
update
Updates the value of the objective function after a selection.- Parameters:
user
- the selected user.selectedItem
- the selected item and its score.
-