Class AblationExperimentExample

java.lang.Object
es.uam.eps.ir.relison.examples.links.recommendation.AblationExperimentExample

public class AblationExperimentExample
extends java.lang.Object
A learning to rank experiment that performs ablation on the different variables. It applies it to the LambdaMART algorithm.
  • Constructor Summary

    Constructors 
    Constructor Description
    AblationExperimentExample()  
  • Method Summary

    Modifier and Type Method Description
    private static java.lang.String errorMessage()
    Obtains the error message for the LETORExperiment main function.
    static void main​(java.lang.String[] args)
    Executes the learning to rank experiment.
    private static void readAndSample​(java.lang.String file, java.lang.String expDirectory, java.util.Map<java.lang.Integer,​java.util.Set<java.lang.Integer>> partitions, int numPartitions, java.lang.String filename)
    Given a LETOR file, and some feature selections, it generates a LETOR file for each selection.
    private static void readAndSampleReducedDiscrete​(java.lang.String file, java.lang.String expDirectory, java.util.Map<java.lang.Integer,​java.util.Set<java.lang.Integer>> partitions, int numPartitions, int numFeats, java.lang.String filename)
    Generates the samples for a collection of datasets.
    private static int readPartitionsFile​(java.lang.String partitionsFile, java.util.Map<java.lang.Integer,​java.util.Set<java.lang.Integer>> map)
    Reads a file specifying the partitions.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • errorMessage

      private static java.lang.String errorMessage()
      Obtains the error message for the LETORExperiment main function.
      Returns:
      the error message.
    • main

      public static void main​(java.lang.String[] args) throws java.io.IOException
      Executes the learning to rank experiment.
      Parameters:
      args - execution arguments
      1. Training instances: A LETOR file containing the training instances.
      2. Validation instances: A LETOR file containing the validation instances.
      3. Test instances: A LETOR file containing the test instances.
      4. Partitions: A configuration file. On each row, it includes a comma separated list of values. Each value corresponds to the index of a feature in the LETOR files.
      5. Experiment directory: The route to the directory in which to the output the experiment will be stored.
      6. Terrier/JForests: The route to the Terrier/JForests binary file.
      7. JForest properties: The route to the properties file for LambdaMART in the JForests/Terrier library
      8. Training graph: The route for the training network.
      9. Test graph: The route to the test graph.
      10. Directed: true if the network is directed, false otherwise.
      11. Weighted: true if the network is weighted, false otherwise.
      12. Rec. ouput: directory in which to store the outcome of the recommendations.
      13. Cut-off: cut-off of the recommendations.
      14. Sample: true if we need to generate the instances for each feature selection, false otherwise.
      15. Copy: true if we need to generate the reduced instances for each feature selection, false otherwise.
      Throws:
      java.io.IOException - if something fails while reading/ writing.
    • readPartitionsFile

      private static int readPartitionsFile​(java.lang.String partitionsFile, java.util.Map<java.lang.Integer,​java.util.Set<java.lang.Integer>> map) throws java.io.IOException
      Reads a file specifying the partitions.
      Parameters:
      partitionsFile - the partitions file.
      map - the map to configure. It has the feature index as key, and the numbers of configurations containing the feature as values.
      Returns:
      the number of partitions.
      Throws:
      java.io.IOException - if something fails while reading the file.
    • readAndSample

      private static void readAndSample​(java.lang.String file, java.lang.String expDirectory, java.util.Map<java.lang.Integer,​java.util.Set<java.lang.Integer>> partitions, int numPartitions, java.lang.String filename) throws java.io.IOException
      Given a LETOR file, and some feature selections, it generates a LETOR file for each selection.
      Parameters:
      file - the route to the LETOR file.
      expDirectory - a directory in which we want to store the files.
      partitions - the different feature selections.
      numPartitions - the number of different feature selections.
      filename - the name of the new files.
      Throws:
      java.io.IOException - if something fails while reading / writing.
    • readAndSampleReducedDiscrete

      private static void readAndSampleReducedDiscrete​(java.lang.String file, java.lang.String expDirectory, java.util.Map<java.lang.Integer,​java.util.Set<java.lang.Integer>> partitions, int numPartitions, int numFeats, java.lang.String filename) throws java.io.IOException
      Generates the samples for a collection of datasets.
      Parameters:
      file - the file.
      expDirectory - the directory in which to store the file.
      partitions - the different partitions.
      numPartitions - the number of partitions.
      numFeats - the number of features
      filename - the name of the file.
      Throws:
      java.io.IOException - if something fails while reading / writing.