Search in sources :

Example 11 with Simulations

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);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) SemBicTest(edu.cmu.tetrad.algcomparison.independence.SemBicTest) Parameters(edu.cmu.tetrad.util.Parameters) ScoreWrapper(edu.cmu.tetrad.algcomparison.score.ScoreWrapper) Fges(edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Fges) Pcd(edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Pcd) IndependenceWrapper(edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper) Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) Pc(edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Pc) Comparison(edu.cmu.tetrad.algcomparison.Comparison) SemBicScore(edu.cmu.tetrad.algcomparison.score.SemBicScore) FgesD(edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.FgesD)

Example 12 with Simulations

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);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) MultiDataSetAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) File(java.io.File) LoadDataAndGraphs(edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)

Example 13 with Simulations

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);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) MultiDataSetAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) File(java.io.File) LoadDataAndGraphs(edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)

Example 14 with Simulations

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);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) MultiDataSetAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) LoadDataAndGraphs(edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)

Example 15 with Simulations

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);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) MultiDataSetAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) LoadDataAndGraphs(edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)

Aggregations

Simulations (edu.cmu.tetrad.algcomparison.simulation.Simulations)22 Algorithms (edu.cmu.tetrad.algcomparison.algorithm.Algorithms)17 Parameters (edu.cmu.tetrad.util.Parameters)17 Comparison (edu.cmu.tetrad.algcomparison.Comparison)16 RandomForward (edu.cmu.tetrad.algcomparison.graph.RandomForward)10 SemBicScore (edu.cmu.tetrad.algcomparison.score.SemBicScore)9 Algorithm (edu.cmu.tetrad.algcomparison.algorithm.Algorithm)5 ExternalAlgorithm (edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm)4 MultiDataSetAlgorithm (edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm)4 Fges (edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Fges)4 LinearFisherModel (edu.cmu.tetrad.algcomparison.simulation.LinearFisherModel)4 LoadDataAndGraphs (edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)4 FisherZ (edu.cmu.tetrad.algcomparison.independence.FisherZ)3 SemSimulation (edu.cmu.tetrad.algcomparison.simulation.SemSimulation)3 FirstInflection (edu.cmu.tetrad.algcomparison.algorithm.FirstInflection)2 File (java.io.File)2 StARS (edu.cmu.tetrad.algcomparison.algorithm.StARS)1 StabilitySelection (edu.cmu.tetrad.algcomparison.algorithm.StabilitySelection)1 Fask (edu.cmu.tetrad.algcomparison.algorithm.multi.Fask)1 ImagesPcStableMax (edu.cmu.tetrad.algcomparison.algorithm.multi.ImagesPcStableMax)1