Class AbstractClusteringCoefficientReranker<U>

Type Parameters:
U - Type of the users.
All Implemented Interfaces:
GlobalReranker<U,​U>
Direct Known Subclasses:
ClusteringCoefficientComplementReranker, ClusteringCoefficientReranker

public abstract class AbstractClusteringCoefficientReranker<U>
extends GraphSwapReranker<U>
Swap reranker that promotes a metric related to the global clustering coefficient of the network.
See Also:
ClusteringCoefficient
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private boolean promote
    Indicates if the metric has to be promoted or its complement has to be promoted.
    private double triangles
    Number of triangles or closed triplets
    private double triplets
    Number of triplets

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

    graph, recs

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

    Modifier and Type Method Description
    protected void computeGlobalValue()
    Computes the global value of the property we want to enhance.
    protected 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 Pair<java.lang.Double> newcoef​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
    Computes the new clustering coefficient for a given user
    protected Pair<java.lang.Double> newcoefadd​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, double numTriplets, double numTriangles)
    Computes the resulting clustering coefficient from adding a link
    protected Pair<java.lang.Double> newcoefdelete​(U user, org.ranksys.core.util.tuples.Tuple2od<U> old, double numTriplets, double numTriangles)
    Computes the resulting clustering coefficient from removing a link
    protected double novAdd​(U u, org.ranksys.core.util.tuples.Tuple2od<U> itemValue, org.ranksys.core.util.tuples.Tuple2od<U> compared)
    Computes the novelty if an edge is added to the graph
    protected double novAddDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> itemValue, org.ranksys.core.util.tuples.Tuple2od<U> compared)
    Computes the novelty if an edge is replaced by other
    protected double novDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> itemValue, org.ranksys.core.util.tuples.Tuple2od<U> compared)
    Computes the novelty if an edge is removed from the graph
    protected void update​(es.uam.eps.ir.ranksys.core.Recommendation<U,​U> reranked)
    Updates the reranking algorithm values, using a certain recommendation.

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

    nov, rerankRecommendations, update

    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 java.lang.Object

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

    • triplets

      private double triplets
      Number of triplets
    • triangles

      private double triangles
      Number of triangles or closed triplets
    • promote

      private final boolean promote
      Indicates if the metric has to be promoted or its complement has to be promoted.
  • Constructor Details

    • AbstractClusteringCoefficientReranker

      public AbstractClusteringCoefficientReranker​(double lambda, int cutoff, java.util.function.Supplier<Normalizer<U>> norm, Graph<U> graph, boolean promote)
      Constructor
      Parameters:
      lambda - trade-off between the original and novelty score (clustering coefficient)
      cutoff - maximum length of the recommendation ranking
      norm - the normalization scheme.
      graph - the original graph.
      promote - true if the metric has to be promoted, false if the complementary metric has to be promoted.
  • Method Details

    • newcoef

      protected Pair<java.lang.Double> newcoef​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
      Computes the new clustering coefficient for a given user
      Parameters:
      user - The user
      updated - The score for the new recommended user.
      old - The score for the old recommended user.
      Returns:
      the updated number of triplets and triangles
    • newcoefdelete

      protected Pair<java.lang.Double> newcoefdelete​(U user, org.ranksys.core.util.tuples.Tuple2od<U> old, double numTriplets, double numTriangles)
      Computes the resulting clustering coefficient from removing a link
      Parameters:
      user - The origin node of the link
      old - The user to remove along the old score.
      numTriplets - the current number of triplets
      numTriangles - the current number of triangles.
      Returns:
      the updated number of triplets and triangles.
    • newcoefadd

      protected Pair<java.lang.Double> newcoefadd​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, double numTriplets, double numTriangles)
      Computes the resulting clustering coefficient from adding a link
      Parameters:
      user - The origin node of the link
      updated - The user to add along its score.
      numTriplets - the current number of triplets
      numTriangles - the current number of triangles.
      Returns:
      the updated number of triplets and triangles.
    • update

      protected void update​(es.uam.eps.ir.ranksys.core.Recommendation<U,​U> reranked)
      Description copied from class: SwapReranker
      Updates the reranking algorithm values, using a certain recommendation.
      Specified by:
      update in class SwapReranker<U,​U>
      Parameters:
      reranked - the recommendation.
    • innerUpdate

      protected void innerUpdate​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
      Description copied from class: GraphSwapReranker
      Updates the different parameters of the reranker, further than changing the edges in the graph.
      Specified by:
      innerUpdate in class GraphSwapReranker<U>
      Parameters:
      user - the target user.
      updated - the new candidate user.
      old - the old candidate user.
    • novAddDelete

      protected double novAddDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> itemValue, org.ranksys.core.util.tuples.Tuple2od<U> compared)
      Description copied from class: GraphSwapReranker
      Computes the novelty if an edge is replaced by other
      Specified by:
      novAddDelete in class GraphSwapReranker<U>
      Parameters:
      u - user to be recommended.
      itemValue - the new recommendation
      compared - the old recommendation
      Returns:
      the novelty score.
    • novAdd

      protected double novAdd​(U u, org.ranksys.core.util.tuples.Tuple2od<U> itemValue, org.ranksys.core.util.tuples.Tuple2od<U> compared)
      Description copied from class: GraphSwapReranker
      Computes the novelty if an edge is added to the graph
      Specified by:
      novAdd in class GraphSwapReranker<U>
      Parameters:
      u - user to be recommended.
      itemValue - the new recommendation
      compared - the old recommendation
      Returns:
      the novelty score.
    • novDelete

      protected double novDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> itemValue, org.ranksys.core.util.tuples.Tuple2od<U> compared)
      Description copied from class: GraphSwapReranker
      Computes the novelty if an edge is removed from the graph
      Specified by:
      novDelete in class GraphSwapReranker<U>
      Parameters:
      u - user to be recommended.
      itemValue - the new recommendation
      compared - the old recommendation
      Returns:
      the novelty score.
    • computeGlobalValue

      protected void computeGlobalValue()
      Description copied from class: GraphSwapReranker
      Computes the global value of the property we want to enhance.
      Specified by:
      computeGlobalValue in class GraphSwapReranker<U>