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.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • main

      public static void main​(java.lang.String[] args) throws java.io.IOException
      Program for recommending and evaluating contact recommendation approaches.
      Parameters:
      args - Execution arguments:
      1. Train: Route to the file containing the training graph.
      2. Test: Route to the file containing the test links.
      3. Multigraph: true if the network allows multiple edges, false otherwise.
      4. Directed: true if the network is directed, false otherwise.
      5. Weighted: true if the network is weighted, false otherwise.
      6. Selfloops: true if the network allows self-loops, false otherwise.
      7. ReadTypes: true if we have to read the edge types from the file, false otherwise.
      8. Algorithms: Route to a YAML file containing the recommender configurations.
      9. Output directory: Directory in which to store the recommendations and the output file.
      10. 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.IOException
      Computes 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.