Class LinkPrediction
java.lang.Object
es.uam.eps.ir.relison.examples.links.prediction.LinkPrediction
public class LinkPrediction
extends java.lang.Object
Class for executing and evaluating link prediction approaches.
-
Constructor Summary
Constructors Constructor Description LinkPrediction()
-
Method Summary
Modifier and Type Method Description static java.util.Map<java.lang.String,java.lang.Double>
computeAndEvaluate(LinkPredictor<java.lang.Long> predictor, java.util.function.Predicate<Pair<java.lang.Long>> filter, Graph<java.lang.Long> testGraph, java.util.Map<java.lang.String,LinkPredictionMetric<java.lang.Long>> metrics)
Computes a link prediction and evaluates it using metrics.static java.util.Map<java.lang.String,java.lang.Double>
computeAndEvaluate(java.lang.String output, LinkPredictor<java.lang.Long> predictor, java.util.function.Predicate<Pair<java.lang.Long>> filter, Graph<java.lang.Long> testGraph, java.util.Map<java.lang.String,LinkPredictionMetric<java.lang.Long>> metrics)
Computes a link prediction and evaluates it using metrics.static void
main(java.lang.String[] args)
Program for recommending and evaluating contact recommendation approaches.
-
Constructor Details
-
LinkPrediction
public LinkPrediction()
-
-
Method Details
-
main
public static void main(java.lang.String[] args) throws java.io.IOExceptionProgram for recommending and evaluating contact recommendation approaches.- Parameters:
args
- Execution arguments:- Train: Route to the file containing the training graph.
- Test: Route to the file containing the test links.
- Multigraph: true if the network allows multiple edges, false otherwise.
- Directed: true if the network is directed, false otherwise.
- Weighted: true if the network is weighted, false otherwise.
- Selfloops: true if the network allows self-loops, false otherwise.
- ReadTypes: true if we have to read the edge types from the file, false otherwise.
- Algorithms: Route to a YAML file containing the recommender configurations.
- Output directory: Directory in which to store the recommendations and the output file.
- Optional arguments:
- -users test/all: selects the subset of users for whom we generate recommendation (all of them, or just those in test.
- -print value: true if, additionally to the results, you want to print the recommendations, false otherwise (by default, true)
- -reciprocal value: true if we want to recommend reciprocal links, false otherwise (by default, false)
- -distance max directed: if we want to limit the maximum distance from the target user to the recommended ones. max indicates the distance value whereas directed indicates if we measure the distance over a directed (true) or undirected graph (false). By default, distance is not limited.
- -feat-data file index: if we want to compute feature-dependant metrics, this contains the feature information. File indicates the route to the file, whereas index is true if we have to read the features from an inverted index.
- -comms commFile: a route to a file specifying the communities of the users (by default, all users belong to the same community)
- Throws:
java.io.IOException
- if something fails while reading / writing.
-
computeAndEvaluate
public static java.util.Map<java.lang.String,java.lang.Double> computeAndEvaluate(java.lang.String output, LinkPredictor<java.lang.Long> predictor, java.util.function.Predicate<Pair<java.lang.Long>> filter, Graph<java.lang.Long> testGraph, java.util.Map<java.lang.String,LinkPredictionMetric<java.lang.Long>> metrics) throws java.io.IOExceptionComputes a link prediction and evaluates it using metrics.- Parameters:
output
- route of the file in which to store the link prediction.predictor
- the link prediction algorithm to apply.filter
- the filter for selecting which links can be predicted.testGraph
- the test graph for the evaluation.metrics
- the metrics to evaluate- Returns:
- the value of the metrics.
- Throws:
java.io.IOException
- if something fails during the writing / reading of the recommendation file.
-
computeAndEvaluate
public static java.util.Map<java.lang.String,java.lang.Double> computeAndEvaluate(LinkPredictor<java.lang.Long> predictor, java.util.function.Predicate<Pair<java.lang.Long>> filter, Graph<java.lang.Long> testGraph, java.util.Map<java.lang.String,LinkPredictionMetric<java.lang.Long>> metrics)Computes a link prediction and evaluates it using metrics.- Parameters:
predictor
- the link prediction algorithm to apply.filter
- the filter for selecting which links can be predicted.testGraph
- the test graph for the evaluation.metrics
- the metrics to evaluate- Returns:
- the value of the metrics.
-