Class GlobalRankingGreedyReranker<U,​I>

java.lang.Object
es.uam.eps.ir.relison.links.recommendation.reranking.global.globalranking.GlobalRankingGreedyReranker<U,​I>
Type Parameters:
U - type of the users
I - type of the items
All Implemented Interfaces:
GlobalReranker<U,​I>
Direct Known Subclasses:
GlobalRankingLambdaReranker

public abstract class GlobalRankingGreedyReranker<U,​I>
extends java.lang.Object
implements GlobalReranker<U,​I>
Implementation of a greedy reranking strategy for optimizing global properties of the system. This reranker chooses the items which have a more significant impact on the global property to optimize. Given a set of recommendations for different users, these rerankers iteratively choose the user-item pair that maximizes a given objective function. A user can only be selected as long as the ranking does not have enough items.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected int cutOff
    The number of recommended items that are reranked for each user.
    private org.ranksys.core.util.tuples.Tuple2id maxItemScore
    Item that achieves the maximum score and its value.
    private double maxScore
    Maximum score of an item.
    private U maxUser
    User that achieves the maximum value.
  • Constructor Summary

    Constructors 
    Constructor Description
    GlobalRankingGreedyReranker​(int cutOff)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    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 double score​(U user, org.ranksys.core.util.tuples.Tuple2od<I> item)
    Computes the score of a recommendation item
    protected Tuple2oo<U,​org.ranksys.core.util.tuples.Tuple2id> selectRecommendation​(java.util.Map<U,​java.util.List<org.ranksys.core.util.tuples.Tuple2od<I>>> remainingItems)
    Selects the next recommendation to add to the reranked one.
    protected abstract void update​(U user, org.ranksys.core.util.tuples.Tuple2od<I> selectedItem)
    Updates the value of the objective function after a selection.

    Methods inherited from class java.lang.Object

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

    • cutOff

      protected final int cutOff
      The number of recommended items that are reranked for each user.
    • maxScore

      private double maxScore
      Maximum score of an item.
    • maxUser

      private U maxUser
      User that achieves the maximum value.
    • maxItemScore

      private org.ranksys.core.util.tuples.Tuple2id maxItemScore
      Item that achieves the maximum score and its value.
  • Constructor Details

  • 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>
      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.
    • selectRecommendation

      protected Tuple2oo<U,​org.ranksys.core.util.tuples.Tuple2id> selectRecommendation​(java.util.Map<U,​java.util.List<org.ranksys.core.util.tuples.Tuple2od<I>>> remainingItems)
      Selects the next recommendation to add to the reranked one.
      Parameters:
      remainingItems - the remaining items.
      Returns:
      a tuple containing the recommendation to add.
    • score

      protected abstract double score​(U user, org.ranksys.core.util.tuples.Tuple2od<I> item)
      Computes the score of a recommendation item
      Parameters:
      user - the user
      item - the original value.
      Returns:
      the new score.
    • update

      protected abstract void update​(U user, org.ranksys.core.util.tuples.Tuple2od<I> selectedItem)
      Updates the value of the objective function after a selection.
      Parameters:
      user - the selected user.
      selectedItem - the selected item and its score.