Search in sources :

Example 6 with SemSimulation

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

the class TestFges method testFromData.

@Test
public void testFromData() {
    Parameters parameters = new Parameters();
    parameters.set("standardize", false);
    parameters.set("measurementVariance", 0);
    parameters.set("numRuns", 1);
    parameters.set("differentGraphs", true);
    parameters.set("sampleSize", 1000);
    parameters.set("numMeasures", 100);
    parameters.set("numLatents", 0);
    parameters.set("avgDegree", 6);
    // parameters.set("maxDegree", 100);
    // parameters.set("maxIndegree", 100);
    // parameters.set("maxOutdegree", 100);
    parameters.set("symmetricFirstStep", true);
    parameters.set("faithfulnessAssumed", false);
    parameters.set("penaltyDisount", 2);
    parameters.set("alpha", 0.001);
    parameters.set("coefLow", 0.2);
    parameters.set("coefHigh", 0.9);
    parameters.set("varLow", 1);
    parameters.set("varHigh", 3);
    parameters.set("coefSymmetric", true);
    parameters.set("covSymmetric", true);
    parameters.set("randomizeColumns", true);
    SemSimulation simulation = new SemSimulation(new RandomForward());
    simulation.createData(parameters);
    Graph dag = simulation.getTrueGraph(0);
    DataModel dataSet = simulation.getDataModel(0);
    edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.PcFges pcFges = new edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.PcFges(new edu.cmu.tetrad.algcomparison.score.SemBicScore(), false);
    long start = System.currentTimeMillis();
    Graph graph = pcFges.search(dataSet, parameters);
    long stop = System.currentTimeMillis();
    System.out.println("Elapsed " + (stop - start) + " ms");
    graph = GraphUtils.replaceNodes(graph, dag.getNodes());
    System.out.println(MisclassificationUtils.edgeMisclassifications(graph, dag));
}
Also used : SemSimulation(edu.cmu.tetrad.algcomparison.simulation.SemSimulation) RandomForward(edu.cmu.tetrad.algcomparison.graph.RandomForward) RandomGraph(edu.cmu.tetrad.algcomparison.graph.RandomGraph) SemBicDTest(edu.cmu.tetrad.algcomparison.independence.SemBicDTest) SemBicTest(edu.cmu.tetrad.algcomparison.independence.SemBicTest) Test(org.junit.Test)

Example 7 with SemSimulation

use of edu.cmu.tetrad.algcomparison.simulation.SemSimulation 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)

Aggregations

RandomForward (edu.cmu.tetrad.algcomparison.graph.RandomForward)7 SemSimulation (edu.cmu.tetrad.algcomparison.simulation.SemSimulation)7 Comparison (edu.cmu.tetrad.algcomparison.Comparison)4 Parameters (edu.cmu.tetrad.util.Parameters)4 Simulations (edu.cmu.tetrad.algcomparison.simulation.Simulations)3 Algorithms (edu.cmu.tetrad.algcomparison.algorithm.Algorithms)2 RandomGraph (edu.cmu.tetrad.algcomparison.graph.RandomGraph)2 FisherZ (edu.cmu.tetrad.algcomparison.independence.FisherZ)2 Simulation (edu.cmu.tetrad.algcomparison.simulation.Simulation)2 Cyclic (edu.cmu.tetrad.algcomparison.graph.Cyclic)1 RandomSingleFactorMim (edu.cmu.tetrad.algcomparison.graph.RandomSingleFactorMim)1 RandomTwoFactorMim (edu.cmu.tetrad.algcomparison.graph.RandomTwoFactorMim)1 ScaleFree (edu.cmu.tetrad.algcomparison.graph.ScaleFree)1 SingleGraph (edu.cmu.tetrad.algcomparison.graph.SingleGraph)1 SemBicDTest (edu.cmu.tetrad.algcomparison.independence.SemBicDTest)1 SemBicTest (edu.cmu.tetrad.algcomparison.independence.SemBicTest)1 SemBicScore (edu.cmu.tetrad.algcomparison.score.SemBicScore)1 BayesNetSimulation (edu.cmu.tetrad.algcomparison.simulation.BayesNetSimulation)1 ConditionalGaussianSimulation (edu.cmu.tetrad.algcomparison.simulation.ConditionalGaussianSimulation)1 GeneralSemSimulation (edu.cmu.tetrad.algcomparison.simulation.GeneralSemSimulation)1