Class AbstractLinkPredictor<U>
java.lang.Object
es.uam.eps.ir.relison.links.linkprediction.AbstractLinkPredictor<U>
- Type Parameters:
U
- type of the users.
- All Implemented Interfaces:
LinkPredictor<U>
- Direct Known Subclasses:
InstancePostfixExLinkPredictor
,RecommendationLinkPredictor
,SupervisedLinkPredictor
public abstract class AbstractLinkPredictor<U> extends java.lang.Object implements LinkPredictor<U>
Abstract definition of a link prediction algorithm.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractLinkPredictor(Graph<U> graph)
Constructor.AbstractLinkPredictor(Graph<U> graph, java.util.Comparator<org.ranksys.core.util.tuples.Tuple2od<Pair<U>>> comparator)
Constructor. -
Method Summary
Modifier and Type Method Description protected java.util.Comparator<org.ranksys.core.util.tuples.Tuple2od<Pair<U>>>
getComparator()
Obtains the comparator for ordering the nodes.protected Graph<U>
getGraph()
Obtains the graph over which we execute the link prediction algorithmPrediction<U>
getPrediction()
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm.Prediction<U>
getPrediction(int maxLength)
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm and returns the a limited set of them.abstract Prediction<U>
getPrediction(int maxLength, java.util.function.Predicate<Pair<U>> filter)
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm.Prediction<U>
getPrediction(java.util.function.Predicate<Pair<U>> filter)
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm.Prediction<U>
getPrediction(java.util.stream.Stream<Pair<U>> candidates)
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm.double
getPredictionScore(U u, U v)
Obtains the prediction score for a pair of candidates.
-
Field Details
-
graph
The social network. -
comparator
The comparator of pairs to return a sorted list.
-
-
Constructor Details
-
AbstractLinkPredictor
public AbstractLinkPredictor(Graph<U> graph, java.util.Comparator<org.ranksys.core.util.tuples.Tuple2od<Pair<U>>> comparator)Constructor.- Parameters:
graph
- the social network.comparator
- a comparator for reordering the pairs.
-
AbstractLinkPredictor
Constructor. By default, sorts the pairs in descending score order.- Parameters:
graph
- the social network.
-
-
Method Details
-
getPrediction
Description copied from interface:LinkPredictor
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm.- Specified by:
getPrediction
in interfaceLinkPredictor<U>
- Returns:
- a sorted list containing the user-user pairs and the link prediction score (in descending score order).
-
getPrediction
Description copied from interface:LinkPredictor
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm and returns the a limited set of them.- Specified by:
getPrediction
in interfaceLinkPredictor<U>
- Parameters:
maxLength
- the maximum size of the link prediction list.- Returns:
- a sorted list containing the user-user pairs and the link prediction score (in descending score order).
-
getPrediction
Description copied from interface:LinkPredictor
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm. It only ranks those user pairs which pass a given filter.- Specified by:
getPrediction
in interfaceLinkPredictor<U>
- Parameters:
filter
- a filter to indicate which user pairs shall be ranked.- Returns:
- a sorted list containing the user-user pairs and the link prediction score (in descending score order).
-
getPrediction
public abstract Prediction<U> getPrediction(int maxLength, java.util.function.Predicate<Pair<U>> filter)Description copied from interface:LinkPredictor
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm. It only ranks those user pairs which pass a given filter. It returns a limited number of such pairs.- Specified by:
getPrediction
in interfaceLinkPredictor<U>
- Parameters:
maxLength
- the maximum size of the link prediction list.filter
- a filter to indicate which user pairs shall be ranked.- Returns:
- a sorted list containing the user-user pairs and the link prediction score (in descending score order).
-
getPrediction
Description copied from interface:LinkPredictor
Given a social network, ranks the possible user-user pairs, according to the scores given by the algorithm. It only ranks the received user pairs.- Specified by:
getPrediction
in interfaceLinkPredictor<U>
- Parameters:
candidates
- a stream containing the user pairs to rank.- Returns:
- a sorted list containing the user-user pairs and the link prediction score (in descending score order).
-
getPredictionScore
Description copied from interface:LinkPredictor
Obtains the prediction score for a pair of candidates.- Specified by:
getPredictionScore
in interfaceLinkPredictor<U>
- Parameters:
u
- first user in the pair.v
- second user in the pair.- Returns:
- the prediction score.
-
getGraph
Obtains the graph over which we execute the link prediction algorithm- Returns:
- the graph.
-
getComparator
Obtains the comparator for ordering the nodes.- Returns:
- the comparator.
-