Search in sources :

Example 21 with Simulations

use of edu.cmu.tetrad.algcomparison.simulation.Simulations in project tetrad by cmu-phil.

the class TestCopy method main.

/**
 * An example script to simulate data and run a comparison analysis on it.
 *
 * @author jdramsey
 */
public static void main(String... args) {
    Parameters parameters = new Parameters();
    parameters.set("numRuns", 10);
    parameters.set("numMeasures", 100);
    parameters.set("avgDegree", 2, 4, 6);
    parameters.set("sampleSize", 200);
    parameters.set("alpha", 1e-4, 1e-3, 1e-2);
    parameters.set("penaltyDiscount", 1);
    Statistics statistics = new Statistics();
    statistics.add(new ParameterColumn("sampleSize"));
    statistics.add(new ParameterColumn("avgDegree"));
    statistics.add(new ParameterColumn("alpha"));
    statistics.add(new AdjacencyPrecision());
    statistics.add(new AdjacencyRecall());
    statistics.add(new ArrowheadPrecision());
    statistics.add(new ArrowheadRecall());
    statistics.add(new MathewsCorrAdj());
    statistics.add(new MathewsCorrArrow());
    statistics.add(new F1Adj());
    statistics.add(new F1Arrow());
    statistics.add(new SHD());
    statistics.add(new ElapsedTime());
    statistics.setWeight("AP", 1.0);
    statistics.setWeight("AHP", 1.0);
    Algorithms algorithms = new Algorithms();
    algorithms.add(new Pc(new FisherZ()));
    algorithms.add(new PcStableMax(new FisherZ(), false));
    Simulations simulations = new Simulations();
    simulations.add(new SemSimulation(new RandomForward()));
    Comparison comparison = new Comparison();
    comparison.setShowAlgorithmIndices(true);
    comparison.setShowSimulationIndices(true);
    comparison.setSortByUtility(true);
    comparison.setShowUtilities(true);
    comparison.setParallelized(true);
    comparison.compareFromSimulations("comparison", simulations, algorithms, statistics, parameters);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) Parameters(edu.cmu.tetrad.util.Parameters) SemSimulation(edu.cmu.tetrad.algcomparison.simulation.SemSimulation) RandomForward(edu.cmu.tetrad.algcomparison.graph.RandomForward) Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) FisherZ(edu.cmu.tetrad.algcomparison.independence.FisherZ) Comparison(edu.cmu.tetrad.algcomparison.Comparison)

Example 22 with Simulations

use of edu.cmu.tetrad.algcomparison.simulation.Simulations in project tetrad by cmu-phil.

the class TimeoutComparisonTest method testTimeoutComparison.

/**
 * Test of setComparisonGraph method, of class TimeoutComparison.
 *
 * @throws IOException
 */
@Ignore
@Test
public void testTimeoutComparison() throws IOException {
    Parameters parameters = getParameters();
    Statistics statistics = getStatistics();
    Algorithms algorithms = getAlgorithms();
    Simulations simulations = getSimulations();
    String resultsPath = tmpDir.newFolder("comparison").toString();
    TimeoutComparison comparisonEngine = getTetradComparisonEngine();
    comparisonEngine.compareFromSimulations(resultsPath, simulations, algorithms, statistics, parameters, 60, TimeUnit.SECONDS);
    System.out.println("================================================================================");
    System.out.println("Output File:");
    System.out.println("================================================================================");
    Path outputFile = Paths.get(resultsPath, "Comparison.txt");
    if (Files.exists(outputFile)) {
        try (Stream<String> stream = Files.lines(outputFile)) {
            stream.forEach(out::println);
        }
    }
    System.out.println("================================================================================");
}
Also used : Path(java.nio.file.Path) Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) Parameters(edu.cmu.tetrad.util.Parameters) Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) Statistics(edu.cmu.tetrad.algcomparison.statistic.Statistics) System.out(java.lang.System.out) Ignore(org.junit.Ignore) Test(org.junit.Test)

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