Package edu.cmu.tetrad.algcomparison
Class Comparison
java.lang.Object
edu.cmu.tetrad.algcomparison.Comparison
- All Implemented Interfaces:
TetradSerializable
,Serializable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enum of comparison graphs types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
compareFromFiles
(String filePath, Algorithms algorithms, Statistics statistics, Parameters parameters) compareFromFiles.void
compareFromFiles
(String dataPath, String resultsPath, Algorithms algorithms, Statistics statistics, Parameters parameters) Compares algorithms.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.void
compareFromSimulations
(String resultsPath, Simulations simulations, String outputFileName, Algorithms algorithms, Statistics statistics, Parameters parameters) Compares the results obtained from simulations.void
compareFromSimulations
(String resultsPath, Simulations simulations, String outputFileName, PrintStream localOut, Algorithms algorithms, Statistics statistics, Parameters parameters) Compares the results of simulations and generates an output file.void
compareFromSimulations
(String resultsPath, Simulations simulations, String outputFileName, PrintStream localOut, PrintStream localOut2, Algorithms algorithms, Statistics statistics, Parameters parameters) Compares the results of different simulations and algorithms.void
configuration
(String path) Generates a configuration file containing information about available algorithms, statistics, independence tests, scores, and simulations.void
generateReportFromExternalAlgorithms
(String dataPath, String resultsPath, Algorithms algorithms, Statistics statistics, Parameters parameters) Generates a report from external algorithms.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.Returns the ComparisonGraph instance.Retrieves the knowledge.boolean
Checks if the CPDAGs are saved.boolean
Returns the status of whether data is being saved or not.boolean
Checks if the "savePags" variable is true or false.boolean
Checks if the utilities are currently being shown.boolean
Returns whether utility does the sorting.void
saveToFiles
(String dataPath, Simulation simulation, Parameters parameters) Saves the simulation data to file in the specified data path.void
saveToFilesSingleSimulation
(String dataPath, Simulation simulation, Parameters parameters) Saves the results of a single simulation to files.void
setComparisonGraph
(Comparison.ComparisonGraph comparisonGraph) Sets the comparison graph.void
setKnowledge
(Knowledge knowledge) Sets the knowledge for the current instance.void
setParallelism
(int parallelism) Sets the number of threads to be used for parallel processing.void
setSaveCPDAGs
(boolean saveCPDAGs) Sets whether to save CPDAGs.void
setSaveData
(boolean saveData) Sets the flag indicating whether to save data.void
setSaveGraphs
(boolean saveGraphs) Sets whether to save graphs.void
setSavePags
(boolean savePags) Sets the value of 'savePags' flag.void
setSetAlgorithmKnowledge
(boolean setAlgorithmKnowledge) Sets the algorithm knowledge flag.void
setShowUtilities
(boolean showUtilities) Sets the value of the showUtilities property.void
setSortByUtility
(boolean sortByUtility) Set the flag to determine if utility should do the sorting.void
setTabDelimitedTables
(boolean tabDelimitedTables) Sets the flag indicating whether tab-delimited tables should be used.
-
Constructor Details
-
Comparison
public Comparison()Initializes a new instance of the Comparison class.By default, the saveGraphs property is set to true. The showUtilities and sortByUtility properties are 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
- aString
objectalgorithms
- aAlgorithms
objectstatistics
- aStatistics
objectparameters
- aParameters
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
- aStatistics
objectparameters
- aParameters
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 simulations and generates an output file.- Parameters:
resultsPath
- The path to the directory containing the simulation results.simulations
- The simulations to compare.outputFileName
- The name of the file to generate.localOut
- The print stream to write the output to.algorithms
- The algorithms to use for comparison.statistics
- The statistics to calculate for comparison.parameters
- The parameters for comparison.
-
compareFromSimulations
public void compareFromSimulations(String resultsPath, Simulations simulations, String outputFileName, PrintStream localOut, PrintStream localOut2, Algorithms algorithms, Statistics statistics, Parameters parameters) Compares the results of different simulations and algorithms.- Parameters:
resultsPath
- the path to the results directorysimulations
- the simulation object containing the simulation dataoutputFileName
- the name of the output filelocalOut
- the local output stream; may be null.localOut2
- the second local output stream; may be null.algorithms
- the algorithms object containing the algorithm datastatistics
- the statistics object containing the statistics dataparameters
- the parameter object containing the parameter data
-
saveToFiles
Saves the simulation data to file in the specified data path.- Parameters:
dataPath
- the path where the data files will be savedsimulation
- the simulation object containing the data to be savedparameters
- 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
Generates a configuration file containing information about available algorithms, statistics, independence tests, scores, and simulations.- Parameters:
path
- The path to save the configuration file.
-
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
Returns the ComparisonGraph instance.- Returns:
- the ComparisonGraph instance
-
setComparisonGraph
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
-
getKnowledge
-
setKnowledge
Sets the knowledge for the current instance.- Parameters:
knowledge
- the knowledge to be set
-
setSetAlgorithmKnowledge
public void setSetAlgorithmKnowledge(boolean setAlgorithmKnowledge) Sets the algorithm knowledge flag.- Parameters:
setAlgorithmKnowledge
- the flag value to set
-