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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • relStats

      protected Normalizer<I> relStats
      Statistics for the original scores.
    • novStats

      protected Normalizer<I> novStats
      Statistics for the novelty scores.
    • novMap

      protected it.unimi.dsi.fastutil.objects.Object2DoubleMap<I> novMap
      Novelty of the items.
    • lambda

      private final double lambda
      Trade-off between original and novelty scores.
    • norm

      private final java.util.function.Supplier<Normalizer<I>> norm
      The normalization algorithm to apply.
  • 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 class SwapGreedyReranker<U,​I>
      Parameters:
      u - the target user of the recommendation.
      remainingI - elements outside the top k
      oldValue - 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 class SwapGreedyReranker<U,​I>
      Parameters:
      rec - the recommendation ranking.
      maxLength - the maximum number of items to consider.
      Returns:
      a permutation of the indexes.
    • value

      protected double value​(org.ranksys.core.util.tuples.Tuple2od<I> iv)
      Description copied from class: SwapGreedyReranker
      Computes the value for a item.
      Specified by:
      value in class SwapGreedyReranker<U,​I>
      Parameters:
      iv - the item whose value we want to compute
      Returns:
      the value
    • valuetop

      protected double valuetop​(org.ranksys.core.util.tuples.Tuple2od<I> iv)
      Description copied from class: SwapGreedyReranker
      Computes the value for the top users.
      Specified by:
      valuetop in class SwapGreedyReranker<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 user
      newValue - the value of the new candidate item.
      oldValue - the value of the original candidate item.
      Returns:
      the novelty value