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>
graph
The graph.protected java.util.Map<U,java.util.Set<U>>
recs
The recommendationsFields 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 graphprotected 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 otherprotected 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 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 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
-
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:SwapLambdaReranker
Computes the novelty score of an edge.- Specified by:
nov
in 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:GlobalReranker
Reranks a set of recommendations.- Specified by:
rerankRecommendations
in interfaceGlobalReranker<U,U>
- Overrides:
rerankRecommendations
in 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:SwapGreedyReranker
Updates the value of the global metric.- Specified by:
update
in 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.
-