use of edu.cmu.tetrad.algcomparison.simulation.Simulations in project tetrad by cmu-phil.
the class TestKunMeasurementError method TestCycles_Data_fMRI_FASK.
public void TestCycles_Data_fMRI_FASK() {
Parameters parameters = new Parameters();
parameters.set("numRuns", 20);
parameters.set("penaltyDiscount", 1);
parameters.set("depth", -1);
parameters.set("determinismThreshold", .1);
parameters.set("verbose", true);
parameters.set("symmetricFirstStep", false);
parameters.set("faithfulnessAssumed", false);
parameters.set("maxDegree", 100);
Statistics statistics = new Statistics();
// statistics.add(new ParameterColumn("determinismThreshold"));
statistics.add(new AdjacencyPrecision());
statistics.add(new AdjacencyRecall());
statistics.add(new ArrowheadPrecision());
statistics.add(new ArrowheadRecall());
Simulations simulations = new Simulations();
// String dir = "/Users/user/Downloads/Simul1_T500";
String dir = "/Users/user/Downloads/Simul1_T2000";
// String dir = "/Users/user/Downloads/Simul2_T500";
// String dir = "/Users/user/Downloads/Simul2_T2000";
simulations.add(new LoadContinuousDataAndSingleGraphKun(dir, "Cov_X"));
simulations.add(new LoadContinuousDataAndSingleGraphKun(dir, "Cov_tilde"));
simulations.add(new LoadContinuousDataAndSingleGraphKun(dir, "Cov_tilde_hat"));
//
Algorithms algorithms = new Algorithms();
IndependenceWrapper test = new SemBicTest();
ScoreWrapper score = new SemBicScore();
algorithms.add(new Pc(test));
algorithms.add(new Fges(score));
algorithms.add(new Pcd());
algorithms.add(new FgesD());
Comparison comparison = new Comparison();
comparison.setShowAlgorithmIndices(true);
comparison.setShowSimulationIndices(true);
comparison.setSortByUtility(false);
comparison.setShowUtilities(false);
comparison.setParallelized(false);
comparison.setSaveGraphs(false);
comparison.setTabDelimitedTables(false);
comparison.compareFromSimulations("comparison", simulations, algorithms, statistics, parameters);
}
use of edu.cmu.tetrad.algcomparison.simulation.Simulations in project tetrad by cmu-phil.
the class TimeoutComparison method generateReportFromExternalAlgorithms.
public void generateReportFromExternalAlgorithms(String dataPath, String resultsPath, String outputFileName, Algorithms algorithms, Statistics statistics, Parameters parameters, long timeout, TimeUnit unit) {
this.saveGraphs = false;
this.dataPath = dataPath;
this.resultsPath = resultsPath;
for (Algorithm algorithm : algorithms.getAlgorithms()) {
if (!(algorithm instanceof ExternalAlgorithm)) {
throw new IllegalArgumentException("Expecting all algorithms to implement ExternalAlgorithm.");
}
}
Simulations simulations = new Simulations();
File file = new File(this.dataPath, "save");
File[] dirs = file.listFiles();
if (dirs == null) {
throw new NullPointerException("No files in " + file.getAbsolutePath());
}
this.dirs = new ArrayList<String>();
int count = 0;
for (File dir : dirs) {
if (dir.getName().contains("DS_Store")) {
continue;
}
count++;
}
for (int i = 1; i <= count; i++) {
File _dir = new File(dataPath, "save/" + i);
simulations.add(new LoadDataAndGraphs(_dir.getAbsolutePath()));
this.dirs.add(_dir.getAbsolutePath());
}
compareFromSimulations(this.resultsPath, simulations, outputFileName, algorithms, statistics, parameters, timeout, unit);
}
use of edu.cmu.tetrad.algcomparison.simulation.Simulations in project tetrad by cmu-phil.
the class TimeoutComparison method compareFromFiles.
/**
* Compares algorithms.
*
* @param dataPath Path to the directory where data and graph files have
* been saved.
* @param resultsPath Path to the file where the results should be stored.
* @param algorithms The list of algorithms to be compared.
* @param statistics The list of statistics on which to compare the
* algorithm, and their utility weights.
* @param parameters The list of parameters and their values.
*/
public void compareFromFiles(String dataPath, String resultsPath, Algorithms algorithms, Statistics statistics, Parameters parameters, long timeout, TimeUnit unit) {
for (Algorithm algorithm : algorithms.getAlgorithms()) {
if (algorithm instanceof ExternalAlgorithm) {
throw new IllegalArgumentException("Not expecting any implementations of ExternalAlgorithm here.");
}
}
this.dataPath = dataPath;
this.resultsPath = resultsPath;
Simulations simulations = new Simulations();
File file = new File(this.dataPath, "save");
File[] dirs = file.listFiles();
if (dirs == null) {
throw new NullPointerException("No files in " + file.getAbsolutePath());
}
this.dirs = new ArrayList<String>();
int count = 0;
for (File dir : dirs) {
if (dir.getName().contains("DS_Store")) {
continue;
}
count++;
}
for (int i = 1; i <= count; i++) {
File _dir = new File(dataPath, "save/" + i);
simulations.add(new LoadDataAndGraphs(_dir.getAbsolutePath()));
this.dirs.add(_dir.getAbsolutePath());
}
compareFromSimulations(this.resultsPath, simulations, algorithms, statistics, parameters, timeout, unit);
}
use of edu.cmu.tetrad.algcomparison.simulation.Simulations in project tetrad by cmu-phil.
the class Comparison method generateReportFromExternalAlgorithms.
public void generateReportFromExternalAlgorithms(String dataPath, String resultsPath, String outputFileName, Algorithms algorithms, Statistics statistics, Parameters parameters) {
this.saveGraphs = false;
this.dataPath = dataPath;
this.resultsPath = resultsPath;
for (Algorithm algorithm : algorithms.getAlgorithms()) {
if (!(algorithm instanceof ExternalAlgorithm))
throw new IllegalArgumentException("Expecting all algorithms to implement ExternalAlgorithm.");
}
Simulations simulations = new Simulations();
File file = new File(this.dataPath, "save");
File[] dirs = file.listFiles();
if (dirs == null) {
throw new NullPointerException("No files in " + file.getAbsolutePath());
}
this.dirs = new ArrayList<String>();
int count = 0;
for (File dir : dirs) {
if (dir.getName().contains("DS_Store"))
continue;
count++;
}
for (int i = 1; i <= count; i++) {
File _dir = new File(dataPath, "save/" + i);
simulations.add(new LoadDataAndGraphs(_dir.getAbsolutePath()));
this.dirs.add(_dir.getAbsolutePath());
}
compareFromSimulations(this.resultsPath, simulations, outputFileName, algorithms, statistics, parameters);
}
use of edu.cmu.tetrad.algcomparison.simulation.Simulations in project tetrad by cmu-phil.
the class Comparison method compareFromFiles.
/**
* Compares algorithms.
*
* @param dataPath Path to the directory where data and graph files have been saved.
* @param resultsPath Path to the file where the results should be stored.
* @param algorithms The list of algorithms to be compared.
* @param statistics The list of statistics on which to compare the algorithm, and their utility weights.
* @param parameters The list of parameters and their values.
*/
public void compareFromFiles(String dataPath, String resultsPath, Algorithms algorithms, Statistics statistics, Parameters parameters) {
for (Algorithm algorithm : algorithms.getAlgorithms()) {
if (algorithm instanceof ExternalAlgorithm) {
throw new IllegalArgumentException("Not expecting any implementations of ExternalAlgorithm here.");
}
}
this.dataPath = dataPath;
this.resultsPath = resultsPath;
Simulations simulations = new Simulations();
File file = new File(this.dataPath, "save");
File[] dirs = file.listFiles();
if (dirs == null) {
throw new NullPointerException("No files in " + file.getAbsolutePath());
}
this.dirs = new ArrayList<String>();
int count = 0;
for (File dir : dirs) {
if (dir.getName().contains("DS_Store"))
continue;
count++;
}
for (int i = 1; i <= count; i++) {
File _dir = new File(dataPath, "save/" + i);
simulations.add(new LoadDataAndGraphs(_dir.getAbsolutePath()));
this.dirs.add(_dir.getAbsolutePath());
}
compareFromSimulations(this.resultsPath, simulations, algorithms, statistics, parameters);
}
Aggregations