Type Parameters:
U - type of the users.
All Implemented Interfaces:
GlobalReranker<U,​U>
Direct Known Subclasses:
AbstractClusteringCoefficientReranker, AbstractHeuristicNeighborOverlapReranker, AbstractNeighborOverlapReranker, CommunityReranker, DegreeGiniReranker

public abstract class GraphSwapReranker<U>
extends SwapLambdaReranker<U,​U>
Abstract implementation of the swap reranking strategy for the contact recommendation context. The properties we try to optimize here are global properties of social networks (e.g. clustering coefficient).
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected Graph<U> graph
    The graph.
    protected java.util.Map<U,​java.util.Set<U>> recs
    The recommendations

    Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapLambdaReranker

    novMap, novStats, relStats

    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
    GraphSwapReranker​(double lambda, int cutOff, java.util.function.Supplier<Normalizer<U>> norm, Graph<U> graph)
    Constructor
  • Method Summary

    Modifier and Type Method Description
    protected abstract void computeGlobalValue()
    Computes the global value of the property we want to enhance.
    protected abstract void innerUpdate​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
    Updates the different parameters of the reranker, further than changing the edges in the graph.
    protected double nov​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newValue, org.ranksys.core.util.tuples.Tuple2od<U> oldValue)
    Computes the novelty score of an edge.
    protected abstract double novAdd​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newValue, org.ranksys.core.util.tuples.Tuple2od<U> oldValue)
    Computes the novelty if an edge is added to the graph
    protected abstract double novAddDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newValue, org.ranksys.core.util.tuples.Tuple2od<U> oldValue)
    Computes the novelty if an edge is replaced by other
    protected abstract double novDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newValue, org.ranksys.core.util.tuples.Tuple2od<U> oldValue)
    Computes the novelty if an edge is removed from the graph
    java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<U,​U>> rerankRecommendations​(java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<U,​U>> recommendation, int maxLength)
    Reranks a set of recommendations.
    protected void update​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
    Updates the value of the global metric.

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapLambdaReranker

    rerankPermutation, selectItem, value, valuetop

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker

    getBasePerm, rerankRecommendation

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapReranker

    update

    Methods inherited from class java.lang.Object

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

    • graph

      protected final Graph<U> graph
      The graph.
    • recs

      protected final java.util.Map<U,​java.util.Set<U>> recs
      The recommendations
  • Constructor Details

    • GraphSwapReranker

      public GraphSwapReranker​(double lambda, int cutOff, java.util.function.Supplier<Normalizer<U>> norm, Graph<U> graph)
      Constructor
      Parameters:
      cutOff - length of the definitive recommendation rankings.
      lambda - trade-off between relevance and the global metric.
      norm - the normalization strategy.
      graph - the original graph.
  • Method Details

    • nov

      protected double nov​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newValue, org.ranksys.core.util.tuples.Tuple2od<U> oldValue)
      Description copied from class: SwapLambdaReranker
      Computes the novelty score of an edge.
      Specified by:
      nov in class SwapLambdaReranker<U,​U>
      Parameters:
      u - the user
      newValue - the value of the new candidate item.
      oldValue - the value of the original candidate item.
      Returns:
      the novelty value
    • novAddDelete

      protected abstract double novAddDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newValue, org.ranksys.core.util.tuples.Tuple2od<U> oldValue)
      Computes the novelty if an edge is replaced by other
      Parameters:
      u - user to be recommended.
      newValue - the new recommendation
      oldValue - the old recommendation
      Returns:
      the novelty score.
    • novAdd

      protected abstract double novAdd​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newValue, org.ranksys.core.util.tuples.Tuple2od<U> oldValue)
      Computes the novelty if an edge is added to the graph
      Parameters:
      u - user to be recommended.
      newValue - the new recommendation
      oldValue - the old recommendation
      Returns:
      the novelty score.
    • novDelete

      protected abstract double novDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newValue, org.ranksys.core.util.tuples.Tuple2od<U> oldValue)
      Computes the novelty if an edge is removed from the graph
      Parameters:
      u - user to be recommended.
      newValue - the new recommendation
      oldValue - the old recommendation
      Returns:
      the novelty score.
    • rerankRecommendations

      public java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<U,​U>> rerankRecommendations​(java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<U,​U>> recommendation, int maxLength)
      Description copied from interface: GlobalReranker
      Reranks a set of recommendations.
      Specified by:
      rerankRecommendations in interface GlobalReranker<U,​U>
      Overrides:
      rerankRecommendations in class SwapReranker<U,​U>
      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.
    • update

      protected void update​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
      Description copied from class: SwapGreedyReranker
      Updates the value of the global metric.
      Specified by:
      update in class SwapGreedyReranker<U,​U>
      Parameters:
      user - the user whose recommendation we are reranking.
      updated - the new item.
      old - the old item.
    • computeGlobalValue

      protected abstract void computeGlobalValue()
      Computes the global value of the property we want to enhance.
    • innerUpdate

      protected abstract void innerUpdate​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
      Updates the different parameters of the reranker, further than changing the edges in the graph.
      Parameters:
      user - the target user.
      updated - the new candidate user.
      old - the old candidate user.