Class SwapLambdaReranker<U,I>
java.lang.Object
es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapReranker<U,I>
es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker<U,I>
es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapLambdaReranker<U,I>
- Type Parameters:
U- Type of the users.I- Type of the items.
- All Implemented Interfaces:
GlobalReranker<U,I>
- Direct Known Subclasses:
GraphSwapReranker
public abstract class SwapLambdaReranker<U,I> extends SwapGreedyReranker<U,I>
Abstract implementation of the greedy swap strategy that allows to optimize
at the same time the accuracy of the system (given by the original ranking) and the
global property we want to optimize.
We keep for that a trade-off between the original ranking and the new one.
-
Field Summary
Fields Modifier and Type Field Description private doublelambdaTrade-off between original and novelty scores.private java.util.function.Supplier<Normalizer<I>>normThe normalization algorithm to apply.protected it.unimi.dsi.fastutil.objects.Object2DoubleMap<I>novMapNovelty of the items.protected Normalizer<I>novStatsStatistics for the novelty scores.protected Normalizer<I>relStatsStatistics for the original scores.Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker
cutOffFields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapReranker
globalvalue -
Constructor Summary
Constructors Constructor Description SwapLambdaReranker(double lambda, int cutOff, java.util.function.Supplier<Normalizer<I>> norm)Constructor. -
Method Summary
Modifier and Type Method Description protected abstract doublenov(U u, org.ranksys.core.util.tuples.Tuple2od<I> newValue, org.ranksys.core.util.tuples.Tuple2od<I> oldValue)Computes the novelty score of an edge.protected int[]rerankPermutation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int maxLength)Obtains a permutation for a ranking that greedily optimizes the global metric.protected intselectItem(U u, it.unimi.dsi.fastutil.ints.IntSortedSet remainingI, org.ranksys.core.util.tuples.Tuple2od<I> oldValue, java.util.List<org.ranksys.core.util.tuples.Tuple2od<I>> list)Select the next item to add.protected doublevalue(org.ranksys.core.util.tuples.Tuple2od<I> iv)Computes the value for a item.protected doublevaluetop(org.ranksys.core.util.tuples.Tuple2od<I> iv)Computes the value for the top users.Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker
getBasePerm, rerankRecommendation, updateMethods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapReranker
rerankRecommendations, update
-
Field Details
-
Constructor Details
-
SwapLambdaReranker
public SwapLambdaReranker(double lambda, int cutOff, java.util.function.Supplier<Normalizer<I>> norm)Constructor.- Parameters:
cutOff- maximum length of the recommendation ranking.lambda- trade-off between original and novelty scores.norm- the normalization scheme to apply.
-
-
Method Details
-
selectItem
protected int selectItem(U u, it.unimi.dsi.fastutil.ints.IntSortedSet remainingI, org.ranksys.core.util.tuples.Tuple2od<I> oldValue, java.util.List<org.ranksys.core.util.tuples.Tuple2od<I>> list)Description copied from class:SwapGreedyRerankerSelect the next item to add.- Overrides:
selectItemin classSwapGreedyReranker<U,I>- Parameters:
u- the target user of the recommendation.remainingI- elements outside the top koldValue- the element we want to compare with the elements out of the top N.list- list of values for all the elements- Returns:
- the selected item if we have to swap elements, -1 if not.
-
rerankPermutation
protected int[] rerankPermutation(es.uam.eps.ir.ranksys.core.Recommendation<U,I> rec, int maxLength)Description copied from class:SwapGreedyRerankerObtains a permutation for a ranking that greedily optimizes the global metric.- Overrides:
rerankPermutationin classSwapGreedyReranker<U,I>- Parameters:
rec- the recommendation ranking.maxLength- the maximum number of items to consider.- Returns:
- a permutation of the indexes.
-
value
Description copied from class:SwapGreedyRerankerComputes the value for a item.- Specified by:
valuein classSwapGreedyReranker<U,I>- Parameters:
iv- the item whose value we want to compute- Returns:
- the value
-
valuetop
Description copied from class:SwapGreedyRerankerComputes the value for the top users.- Specified by:
valuetopin classSwapGreedyReranker<U,I>- Parameters:
iv- item between the top.- Returns:
- the value for the top users.
-
nov
protected abstract double nov(U u, org.ranksys.core.util.tuples.Tuple2od<I> newValue, org.ranksys.core.util.tuples.Tuple2od<I> oldValue)Computes the novelty score of an edge.- Parameters:
u- the usernewValue- the value of the new candidate item.oldValue- the value of the original candidate item.- Returns:
- the novelty value
-