Search in sources :

Example 1 with Gfci

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;
}
Also used : Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) FisherZ(edu.cmu.tetrad.algcomparison.independence.FisherZ) Gfci(edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci) SemBicScore(edu.cmu.tetrad.algcomparison.score.SemBicScore)

Example 2 with Gfci

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);
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) Gfci(edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci) Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) FisherZ(edu.cmu.tetrad.algcomparison.independence.FisherZ) Comparison(edu.cmu.tetrad.algcomparison.Comparison) SemBicScore(edu.cmu.tetrad.algcomparison.score.SemBicScore)

Example 3 with Gfci

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);
}
Also used : MlBayesIm(edu.cmu.tetrad.bayes.MlBayesIm) Parameters(edu.cmu.tetrad.util.Parameters) ChiSquare(edu.cmu.tetrad.algcomparison.independence.ChiSquare) GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) Gfci(edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci) DataSet(edu.cmu.tetrad.data.DataSet) ScoreWrapper(edu.cmu.tetrad.algcomparison.score.ScoreWrapper) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) IndependenceWrapper(edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper) Graph(edu.cmu.tetrad.graph.Graph) DagToPag(edu.cmu.tetrad.search.DagToPag) BayesIm(edu.cmu.tetrad.bayes.BayesIm) MlBayesIm(edu.cmu.tetrad.bayes.MlBayesIm) BdeuScore(edu.cmu.tetrad.algcomparison.score.BdeuScore) BayesPm(edu.cmu.tetrad.bayes.BayesPm) Test(org.junit.Test) GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)

Example 4 with Gfci

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);
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) Gfci(edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci) DataSet(edu.cmu.tetrad.data.DataSet) ScoreWrapper(edu.cmu.tetrad.algcomparison.score.ScoreWrapper) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) IndependenceWrapper(edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper) Graph(edu.cmu.tetrad.graph.Graph) DagToPag(edu.cmu.tetrad.search.DagToPag) FisherZ(edu.cmu.tetrad.algcomparison.independence.FisherZ) LargeScaleSimulation(edu.cmu.tetrad.sem.LargeScaleSimulation) SemBicScore(edu.cmu.tetrad.algcomparison.score.SemBicScore) Test(org.junit.Test) GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)

Aggregations

Gfci (edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci)4 FisherZ (edu.cmu.tetrad.algcomparison.independence.FisherZ)3 SemBicScore (edu.cmu.tetrad.algcomparison.score.SemBicScore)3 Parameters (edu.cmu.tetrad.util.Parameters)3 Algorithm (edu.cmu.tetrad.algcomparison.algorithm.Algorithm)2 Algorithms (edu.cmu.tetrad.algcomparison.algorithm.Algorithms)2 IndependenceWrapper (edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper)2 ScoreWrapper (edu.cmu.tetrad.algcomparison.score.ScoreWrapper)2 DataSet (edu.cmu.tetrad.data.DataSet)2 Graph (edu.cmu.tetrad.graph.Graph)2 DagToPag (edu.cmu.tetrad.search.DagToPag)2 GeneralBootstrapTest (edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)2 Test (org.junit.Test)2 Comparison (edu.cmu.tetrad.algcomparison.Comparison)1 ChiSquare (edu.cmu.tetrad.algcomparison.independence.ChiSquare)1 BdeuScore (edu.cmu.tetrad.algcomparison.score.BdeuScore)1 BayesIm (edu.cmu.tetrad.bayes.BayesIm)1 BayesPm (edu.cmu.tetrad.bayes.BayesPm)1 MlBayesIm (edu.cmu.tetrad.bayes.MlBayesIm)1 LargeScaleSimulation (edu.cmu.tetrad.sem.LargeScaleSimulation)1