Class GraphSwapReranker<U>
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,U>
es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.GraphSwapReranker<U>
- 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>graphThe graph.protected java.util.Map<U,java.util.Set<U>>recsThe recommendationsFields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapLambdaReranker
novMap, novStats, relStatsFields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker
cutOffFields 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 voidcomputeGlobalValue()Computes the global value of the property we want to enhance.protected abstract voidinnerUpdate(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 doublenov(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 doublenovAdd(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 graphprotected abstract doublenovAddDelete(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 otherprotected abstract doublenovDelete(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 graphjava.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 voidupdate(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, valuetopMethods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker
getBasePerm, rerankRecommendationMethods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapReranker
update
-
Field Details
-
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:SwapLambdaRerankerComputes the novelty score of an edge.- Specified by:
novin classSwapLambdaReranker<U,U>- Parameters:
u- the usernewValue- 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 recommendationoldValue- 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 recommendationoldValue- 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 recommendationoldValue- 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:GlobalRerankerReranks a set of recommendations.- Specified by:
rerankRecommendationsin interfaceGlobalReranker<U,U>- Overrides:
rerankRecommendationsin classSwapReranker<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:SwapGreedyRerankerUpdates the value of the global metric.- Specified by:
updatein classSwapGreedyReranker<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.
-