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 double
lambda
Trade-off between original and novelty scores.private java.util.function.Supplier<Normalizer<I>>
norm
The normalization algorithm to apply.protected it.unimi.dsi.fastutil.objects.Object2DoubleMap<I>
novMap
Novelty of the items.protected Normalizer<I>
novStats
Statistics for the novelty scores.protected Normalizer<I>
relStats
Statistics for the original scores.Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker
cutOff
Fields 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 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.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 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)
Select the next item to add.protected double
value(org.ranksys.core.util.tuples.Tuple2od<I> iv)
Computes the value for a item.protected double
valuetop(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, update
Methods 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:SwapGreedyReranker
Select the next item to add.- Overrides:
selectItem
in 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:SwapGreedyReranker
Obtains a permutation for a ranking that greedily optimizes the global metric.- Overrides:
rerankPermutation
in 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:SwapGreedyReranker
Computes the value for a item.- Specified by:
value
in classSwapGreedyReranker<U,I>
- Parameters:
iv
- the item whose value we want to compute- Returns:
- the value
-
valuetop
Description copied from class:SwapGreedyReranker
Computes the value for the top users.- Specified by:
valuetop
in 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
-