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));
}
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);
}
Aggregations