Class Comparison

java.lang.Object
edu.cmu.tetrad.algcomparison.Comparison
All Implemented Interfaces:
TetradSerializable, Serializable

public class Comparison extends Object implements TetradSerializable
Script to do a comparison of a list of algorithms using a list of statistics and a list of parameters and their values.
Version:
$Id: $Id
Author:
josephramsey, danielmalinsky
See Also:
  • Constructor Details

    • Comparison

      public Comparison()
      Initializes a new instance of the Comparison class.

      By default, the saveGraphs property is set to true. The showSimulationIndices, showAlgorithmIndices, showUtilities, and sortByUtility properties are all set to false.

      Usage: Comparison comparison = new Comparison();

  • Method Details

    • compareFromFiles

      public void compareFromFiles(String filePath, Algorithms algorithms, Statistics statistics, Parameters parameters)

      compareFromFiles.

      Parameters:
      filePath - a String object
      algorithms - a Algorithms object
      statistics - a Statistics object
      parameters - a Parameters object
    • compareFromFiles

      public void compareFromFiles(String dataPath, String resultsPath, Algorithms algorithms, Statistics statistics, Parameters parameters)
      Compares algorithms.
      Parameters:
      dataPath - Path to the directory where data and graph files have been saved.
      resultsPath - Path to the file where the results should be stored.
      algorithms - The list of algorithms to be compared.
      statistics - a Statistics object
      parameters - a Parameters object
    • generateReportFromExternalAlgorithms

      public void generateReportFromExternalAlgorithms(String dataPath, String resultsPath, Algorithms algorithms, Statistics statistics, Parameters parameters)
      Generates a report from external algorithms.
      Parameters:
      dataPath - - The path to the data file.
      resultsPath - - The path to where the report will be saved.
      algorithms - - The algorithms to compare.
      statistics - - The statistics to include in the report.
      parameters - - The parameters to use for the algorithms.
    • generateReportFromExternalAlgorithms

      public void generateReportFromExternalAlgorithms(String dataPath, String resultsPath, String outputFileName, Algorithms algorithms, Statistics statistics, Parameters parameters)
      Generates a report from external algorithms based on the given parameters.
      Parameters:
      dataPath - The path to the data files.
      resultsPath - The path to save the results.
      outputFileName - The name of the output file.
      algorithms - The collection of algorithms to compare.
      statistics - The statistics to include in the report.
      parameters - The additional parameters for the algorithms.
      Throws:
      IllegalArgumentException - if any algorithm in the collection is not an instance of ExternalAlgorithm.
      NullPointerException - if there are no files in the specified data path.
    • compareFromSimulations

      public void compareFromSimulations(String resultsPath, Simulations simulations, Algorithms algorithms, Statistics statistics, Parameters parameters)
      Compare simulation results using the provided parameters and write the comparison results to a file.
      Parameters:
      resultsPath - The path to write the comparison results file.
      simulations - The simulations to compare results from.
      algorithms - The algorithms used in the simulations.
      statistics - The statistics used in the simulations.
      parameters - The parameters used in the simulations.
    • compareFromSimulations

      public void compareFromSimulations(String resultsPath, Simulations simulations, String outputFileName, Algorithms algorithms, Statistics statistics, Parameters parameters)
      Compares the results obtained from simulations.
      Parameters:
      resultsPath - The path to the directory containing the simulation results.
      simulations - The simulations to compare the results from.
      outputFileName - The name of the output file.
      algorithms - The algorithms used in the simulations.
      statistics - The statistics used in the simulations.
      parameters - The parameters used in the simulations.
    • compareFromSimulations

      public void compareFromSimulations(String resultsPath, Simulations simulations, String outputFileName, PrintStream localOut, Algorithms algorithms, Statistics statistics, Parameters parameters)
      Compares the results of different simulations and algorithms.
      Parameters:
      resultsPath - the path to the results directory
      simulations - the simulations object containing the simulation data
      outputFileName - the name of the output file
      localOut - the local output stream
      algorithms - the algorithms object containing the algorithm data
      statistics - the statistics object containing the statistics data
      parameters - the parameters object containing the parameter data
    • saveToFiles

      public void saveToFiles(String dataPath, Simulation simulation, Parameters parameters)
      Saves the simulation data to file in the specified data path.
      Parameters:
      dataPath - the path where the data files will be saved
      simulation - the simulation object containing the data to be saved
      parameters - the parameters used in the simulation
    • saveToFilesSingleSimulation

      public void saveToFilesSingleSimulation(String dataPath, Simulation simulation, Parameters parameters)
      Saves the results of a single simulation to files.
      Parameters:
      dataPath - The path to the directory where the files will be saved.
      simulation - The simulation object containing the data and graphs.
      parameters - The parameters used for the simulation.
    • configuration

      public void configuration(String path)
      Generates a configuration file containing information about available algorithms, statistics, independence tests, scores, and simulations.
      Parameters:
      path - The path to save the configuration file.
    • isShowSimulationIndices

      public boolean isShowSimulationIndices()
      Checks if the simulation indices are currently being shown.
      Returns:
      true if the simulation indices are being shown, false otherwise
    • setShowSimulationIndices

      public void setShowSimulationIndices(boolean showSimulationIndices)
      Sets whether to show simulation indices or not.
      Parameters:
      showSimulationIndices - true to show simulation indices, false otherwise
    • isShowAlgorithmIndices

      public boolean isShowAlgorithmIndices()
      Indicates whether the algorithm indices should be shown.
      Returns:
      true if the algorithm indices should be shown, false otherwise.
    • setShowAlgorithmIndices

      public void setShowAlgorithmIndices(boolean showAlgorithmIndices)
      Sets whether to show algorithm indices.
      Parameters:
      showAlgorithmIndices - true to show algorithm indices, false otherwise
    • isShowUtilities

      public boolean isShowUtilities()
      Checks if the utilities are currently being shown.
      Returns:
      true if the utilities are being shown, false otherwise.
    • setShowUtilities

      public void setShowUtilities(boolean showUtilities)
      Sets the value of the showUtilities property.
      Parameters:
      showUtilities - the new value for the showUtilities property
    • isSortByUtility

      public boolean isSortByUtility()
      Returns whether utility does the sorting.
      Returns:
      true if utility does the sorting, false otherwise.
    • setSortByUtility

      public void setSortByUtility(boolean sortByUtility)
      Set the flag to determine if utility should do the sorting.
      Parameters:
      sortByUtility - a flag indicating whether to sort by utility or not
    • isSaveCPDAGs

      public boolean isSaveCPDAGs()
      Checks if the CPDAGs are saved.
      Returns:
      true if the CPDAGs are saved, false otherwise.
    • setSaveCPDAGs

      public void setSaveCPDAGs(boolean saveCPDAGs)
      Sets whether to save CPDAGs.
      Parameters:
      saveCPDAGs - indicates whether to save CPDAGs or not
    • isSavePags

      public boolean isSavePags()
      Checks if the "savePags" variable is true or false.
      Returns:
      true if the "savePags" variable is true, false otherwise.
    • setSavePags

      public void setSavePags(boolean savePags)
      Sets the value of 'savePags' flag. This method is used to set the value of the 'savePags' flag, which indicates whether the pags should be saved or not.
      Parameters:
      savePags - a boolean value indicating whether to save the pags or not.
    • isSaveData

      public boolean isSaveData()
      Returns the status of whether data is being saved or not.
      Returns:
      true if data is being saved, false otherwise.
    • setSaveData

      public void setSaveData(boolean saveData)
      Sets the flag indicating whether to save data.
      Parameters:
      saveData - true if data should be saved, false otherwise
    • setSaveGraphs

      public void setSaveGraphs(boolean saveGraphs)
      Sets whether to save graphs.
      Parameters:
      saveGraphs - true to save graphs, false otherwise
    • getComparisonGraph

      public Comparison.ComparisonGraph getComparisonGraph()
      Returns the ComparisonGraph instance.
      Returns:
      the ComparisonGraph instance
    • setComparisonGraph

      public void setComparisonGraph(Comparison.ComparisonGraph comparisonGraph)
      Sets the comparison graph.
      Parameters:
      comparisonGraph - the comparison graph to be set
      Throws:
      NullPointerException - if the comparison graph is null
    • setTabDelimitedTables

      public void setTabDelimitedTables(boolean tabDelimitedTables)
      Sets the flag indicating whether tab-delimited tables should be used.
      Parameters:
      tabDelimitedTables - true if tab-delimited tables should be used; false otherwise
    • setParallelism

      public void setParallelism(int parallelism)
      Sets the number of threads to be used for parallel processing. Note that this method does not enforce the actual parallel execution of the code.
      Parameters:
      parallelism - the number of threads to be used for parallel processing