Class LocalRandomReranker<U,​I>

Type Parameters:
U - type of the users.
I - type of the items.
All Implemented Interfaces:
GlobalReranker<U,​I>

public class LocalRandomReranker<U,​I>
extends LocalLambdaReranker<U,​I>
Random reranker. Reorders recommendations (gradually) at random. +
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.util.Map<U,​java.util.Map<I,​java.lang.Double>> map
    A map containing the random scores for the different user-item pairs.
    private int seed
    Random seed.

    Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.local.LocalLambdaReranker

    novMap, novStats, relStats

    Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.local.LocalGreedyReranker

    cutOff
  • Constructor Summary

    Constructors 
    Constructor Description
    LocalRandomReranker​(int cutOff, double lambda, java.util.function.Supplier<Normalizer<I>> norm)
    Constructor.
    LocalRandomReranker​(int cutOff, double lambda, java.util.function.Supplier<Normalizer<I>> norm, int seed)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    protected double nov​(U u, org.ranksys.core.util.tuples.Tuple2od<I> itemValue)
    Novelty score.
    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 void update​(es.uam.eps.ir.ranksys.core.Recommendation<U,​I> reranked)
    Updates the values, given a new recommendation.
    protected void update​(U user, org.ranksys.core.util.tuples.Tuple2od<I> bestItemValue)
    Given a user, and the next value to add, updates the reranker parameters.

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.local.LocalLambdaReranker

    rerankPermutation, selectItem, value

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.local.LocalGreedyReranker

    getBasePerm, rerankRecommendation

    Methods inherited from class java.lang.Object

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

    • seed

      private final int seed
      Random seed.
    • map

      private final java.util.Map<U,​java.util.Map<I,​java.lang.Double>> map
      A map containing the random scores for the different user-item pairs.
  • Constructor Details

    • LocalRandomReranker

      public LocalRandomReranker​(int cutOff, double lambda, java.util.function.Supplier<Normalizer<I>> norm)
      Constructor.
      Parameters:
      cutOff - maximum length of the definitive ranking.
      lambda - trade-off between the original and novelty scores
      norm - the normalization strategy.
    • LocalRandomReranker

      public LocalRandomReranker​(int cutOff, double lambda, java.util.function.Supplier<Normalizer<I>> norm, int seed)
      Constructor.
      Parameters:
      cutOff - maximum length of the definitive ranking.
      lambda - trade-off between the original and novelty scores
      norm - the normalization strategy.
      seed - the random seed.
  • 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 interface GlobalReranker<U,​I>
      Overrides:
      rerankRecommendations in class LocalReranker<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.
    • nov

      protected double nov​(U u, org.ranksys.core.util.tuples.Tuple2od<I> itemValue)
      Description copied from class: LocalLambdaReranker
      Novelty score.
      Specified by:
      nov in class LocalLambdaReranker<U,​I>
      Parameters:
      u - the target user.
      itemValue - the recommended item and its recommendation score.
      Returns:
      the novelty for this pair user-item.
    • update

      protected void update​(U user, org.ranksys.core.util.tuples.Tuple2od<I> bestItemValue)
      Description copied from class: LocalGreedyReranker
      Given a user, and the next value to add, updates the reranker parameters.
      Specified by:
      update in class LocalGreedyReranker<U,​I>
      Parameters:
      user - The user
      bestItemValue - The next value to add at the ranking
    • update

      protected void update​(es.uam.eps.ir.ranksys.core.Recommendation<U,​I> reranked)
      Description copied from class: LocalReranker
      Updates the values, given a new recommendation.
      Specified by:
      update in class LocalReranker<U,​I>
      Parameters:
      reranked - the reranked recommendation.