use of edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci in project tetrad by cmu-phil.
the class TimeoutComparisonTest method getAlgorithms.
private static Algorithms getAlgorithms() {
Algorithms algorithms = new Algorithms();
algorithms.add(new Gfci(new FisherZ(), new SemBicScore()));
return algorithms;
}
use of edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci in project tetrad by cmu-phil.
the class ExampleCompareFromFiles method main.
public static void main(String... args) {
Parameters parameters = new Parameters();
parameters.set("numRuns", 1);
// parameters.set("numMeasures", 20,100,1000);
parameters.set("numMeasures", 1000);
parameters.set("numLatents", 200);
parameters.set("avgDegree", 2);
parameters.set("sampleSize", 1000);
parameters.set("penaltyDisount", 2);
parameters.set("alpha", 1e-4);
Statistics statistics = new Statistics();
statistics.add(new ParameterColumn("avgDegree"));
statistics.add(new ParameterColumn("sampleSize"));
statistics.add(new AdjacencyPrecision());
statistics.add(new AdjacencyRecall());
statistics.add(new ArrowheadPrecision());
statistics.add(new ArrowheadRecall());
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("AR", 0.5);
statistics.setWeight("AHP", 1.0);
statistics.setWeight("AHR", 0.5);
// statistics.setWeight("TP", 1.0);
// statistics.setWeight("TR", 0.5);
Algorithms algorithms = new Algorithms();
// algorithms.add(new Gfci(new ChiSquare(), new BdeuScore()));
// algorithms.add(new Fci(new FisherZ()));
// algorithms.add(new Fci(new ChiSquare()));
// algorithms.add(new Rfci(new ChiSquare()));
// algorithms.add(new Rfci(new FisherZ()));
algorithms.add(new Gfci(new FisherZ(), new SemBicScore()));
// algorithms.add(new Fges(new BdeuScore(),true));
// algorithms.add(new Fges(new DiscreteBicScore(),true));
// algorithms.add(new Fges(new SemBicScore()));
// algorithms.add(new Gfci(new ChiSquare(), new DiscreteBicScore())));
// algorithms.add(new Fges(new BdeuScore()));
// algorithms.add(new Fges(new DiscreteBicScore()));
// algorithms.add(new PcMax(new FisherZ(), false));
// algorithms.add(new PcMax(new ChiSquare(),true));
// algorithms.add(new PcMax(new FisherZ(), false));
// algorithms.add(new Pc(new FisherZ()));
Comparison comparison = new Comparison();
comparison.setShowAlgorithmIndices(true);
comparison.setShowSimulationIndices(false);
comparison.setSortByUtility(true);
comparison.setShowUtilities(true);
comparison.setParallelized(false);
comparison.setSaveGraphs(true);
// DagToPag p = new DagToPag(graph);
comparison.compareFromFiles("comparison", algorithms, statistics, parameters);
}
use of edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci in project tetrad by cmu-phil.
the class TestGeneralBootstrapTest method testGFCId.
@Test
public void testGFCId() {
double structurePrior = 1, samplePrior = 1;
boolean faithfulnessAssumed = false;
int maxDegree = -1;
int numVars = 20;
int edgesPerNode = 2;
int numLatentConfounders = 4;
int numCases = 50;
int numBootstrapSamples = 5;
boolean verbose = true;
long seed = 123;
Graph dag = makeDiscreteDAG(numVars, numLatentConfounders, edgesPerNode);
DagToPag dagToPag = new DagToPag(dag);
Graph truePag = dagToPag.convert();
System.out.println("Truth PAG_of_the_true_DAG Graph:");
System.out.println(truePag.toString());
BayesPm pm = new BayesPm(dag, 2, 3);
BayesIm im = new MlBayesIm(pm, MlBayesIm.RANDOM);
DataSet data = im.simulateData(numCases, seed, false);
Parameters parameters = new Parameters();
parameters.set("structurePrior", structurePrior);
parameters.set("samplePrior", samplePrior);
parameters.set("faithfulnessAssumed", faithfulnessAssumed);
parameters.set("maxDegree", maxDegree);
parameters.set("numPatternsToStore", 0);
parameters.set("verbose", verbose);
ScoreWrapper score = new BdeuScore();
IndependenceWrapper test = new ChiSquare();
Algorithm algorithm = new Gfci(test, score);
GeneralBootstrapTest bootstrapTest = new GeneralBootstrapTest(data, algorithm, numBootstrapSamples);
bootstrapTest.setVerbose(verbose);
bootstrapTest.setParameters(parameters);
bootstrapTest.setEdgeEnsemble(BootstrapEdgeEnsemble.Highest);
Graph resultGraph = bootstrapTest.search();
System.out.println("Estimated Bootstrapped PAG_of_the_true_DAG Graph:");
System.out.println(resultGraph.toString());
// Adjacency Confusion Matrix
int[][] adjAr = GeneralBootstrapTest.getAdjConfusionMatrix(truePag, resultGraph);
printAdjConfusionMatrix(adjAr);
// Edge Type Confusion Matrix
int[][] edgeAr = GeneralBootstrapTest.getEdgeTypeConfusionMatrix(truePag, resultGraph);
printEdgeTypeConfusionMatrix(edgeAr);
}
use of edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci in project tetrad by cmu-phil.
the class TestGeneralBootstrapTest method testGFCIc.
@Test
public void testGFCIc() {
int penaltyDiscount = 2;
boolean faithfulnessAssumed = false;
int maxDegree = -1;
int numVars = 20;
int edgesPerNode = 2;
int numLatentConfounders = 2;
int numCases = 50;
int numBootstrapSamples = 5;
boolean verbose = true;
Graph dag = makeContinuousDAG(numVars, numLatentConfounders, edgesPerNode);
DagToPag dagToPag = new DagToPag(dag);
Graph truePag = dagToPag.convert();
System.out.println("Truth PAG_of_the_true_DAG Graph:");
System.out.println(truePag.toString());
int[] causalOrdering = new int[numVars];
for (int i = 0; i < numVars; i++) {
causalOrdering[i] = i;
}
LargeScaleSimulation simulator = new LargeScaleSimulation(dag, dag.getNodes(), causalOrdering);
DataSet data = simulator.simulateDataFisher(numCases);
Parameters parameters = new Parameters();
parameters.set("penaltyDiscount", penaltyDiscount);
parameters.set("faithfulnessAssumed", faithfulnessAssumed);
parameters.set("maxDegree", maxDegree);
parameters.set("numPatternsToStore", 0);
parameters.set("verbose", verbose);
ScoreWrapper score = new SemBicScore();
IndependenceWrapper test = new FisherZ();
Algorithm algorithm = new Gfci(test, score);
GeneralBootstrapTest bootstrapTest = new GeneralBootstrapTest(data, algorithm, numBootstrapSamples);
bootstrapTest.setVerbose(verbose);
bootstrapTest.setParameters(parameters);
bootstrapTest.setEdgeEnsemble(BootstrapEdgeEnsemble.Highest);
Graph resultGraph = bootstrapTest.search();
System.out.println("Estimated PAG_of_the_true_DAG Graph:");
System.out.println(resultGraph.toString());
// Adjacency Confusion Matrix
int[][] adjAr = GeneralBootstrapTest.getAdjConfusionMatrix(truePag, resultGraph);
printAdjConfusionMatrix(adjAr);
// Edge Type Confusion Matrix
int[][] edgeAr = GeneralBootstrapTest.getEdgeTypeConfusionMatrix(truePag, resultGraph);
printEdgeTypeConfusionMatrix(edgeAr);
}
Aggregations