Class SwapReranker<U,I>
java.lang.Object
es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapReranker<U,I>
- Type Parameters:
U
- type of the users.I
- type of the items.
- All Implemented Interfaces:
GlobalReranker<U,I>
- Direct Known Subclasses:
SwapGreedyReranker
public abstract class SwapReranker<U,I> extends java.lang.Object implements GlobalReranker<U,I>
Abstract implementation for a family of reranking strategies for optimizing a global
parameter of the recommendations (e.g. Gini).
These reranking strategies start from a system which has a certain value of the property
to optimize. Then, the rerankers consider an initial scenario where all the user-item pairs
among the top-k recommended items for each user are added to the system.
Then, we run over the top-k recommended items. For each of them, we check whether it is better
to keep this item in the ranking, or choose one of the remaining (the not recommended ones) instead.
If we decide that it is better to change them, we swap them, and update the global property accordingly.
-
Field Summary
Fields Modifier and Type Field Description protected double
globalvalue
Current global value of the metric.private long
seed
Seed for the order of the users -
Constructor Summary
Constructors Constructor Description SwapReranker()
Constructor.SwapReranker(long seed)
Constructor. -
Method Summary
Modifier and Type Method Description protected abstract es.uam.eps.ir.ranksys.core.Recommendation<U,I>
rerankRecommendation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int maxLength)
Reranks the recommendation for a user.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 void
update(es.uam.eps.ir.ranksys.core.Recommendation<U,I> reranked)
Updates the reranking algorithm values, using a certain recommendation.
-
Field Details
-
seed
private final long seedSeed for the order of the users -
globalvalue
protected double globalvalueCurrent global value of the metric.
-
-
Constructor Details
-
SwapReranker
public SwapReranker()Constructor. Default seed, not randomly chosen. -
SwapReranker
public SwapReranker(long seed)Constructor.- Parameters:
seed
- random seed for establishing the order in which we run over the users.
-
-
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.
-
update
Updates the reranking algorithm values, using a certain recommendation.- Parameters:
reranked
- the recommendation.
-
rerankRecommendation
protected abstract es.uam.eps.ir.ranksys.core.Recommendation<U,I> rerankRecommendation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int maxLength)Reranks the recommendation for a user.- Parameters:
rec
- the original recommendation.maxLength
- maximum length of the definitive ranking.- Returns:
- the new recommendation.
-