Search in sources :

Example 36 with GeneralBootstrapTest

use of edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest in project tetrad by cmu-phil.

the class SkewE method search.

@Override
public Graph search(DataModel dataSet, Parameters parameters) {
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        Graph graph = algorithm.search(dataSet, parameters);
        if (graph != null) {
            initialGraph = graph;
        } else {
            throw new IllegalArgumentException("This SkewE algorithm needs both data and a graph source as inputs; it \n" + "will orient the edges in the input graph using the data");
        }
        List<DataSet> dataSets = new ArrayList<>();
        dataSets.add(DataUtils.getContinuousDataSet(dataSet));
        Lofs2 lofs = new Lofs2(initialGraph, dataSets);
        lofs.setRule(Lofs2.Rule.SkewE);
        return lofs.orient();
    } else {
        SkewE skewE = new SkewE(algorithm);
        if (initialGraph != null) {
            skewE.setInitialGraph(initialGraph);
        }
        DataSet data = (DataSet) dataSet;
        GeneralBootstrapTest search = new GeneralBootstrapTest(data, skewE, parameters.getInt("bootstrapSampleSize"));
        BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
        switch(parameters.getInt("bootstrapEnsemble", 1)) {
            case 0:
                edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
                break;
            case 1:
                edgeEnsemble = BootstrapEdgeEnsemble.Highest;
                break;
            case 2:
                edgeEnsemble = BootstrapEdgeEnsemble.Majority;
        }
        search.setEdgeEnsemble(edgeEnsemble);
        search.setParameters(parameters);
        search.setVerbose(parameters.getBoolean("verbose"));
        return search.search();
    }
}
Also used : Lofs2(edu.cmu.tetrad.search.Lofs2) EdgeListGraph(edu.cmu.tetrad.graph.EdgeListGraph) TakesInitialGraph(edu.cmu.tetrad.algcomparison.utils.TakesInitialGraph) Graph(edu.cmu.tetrad.graph.Graph) GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) BootstrapEdgeEnsemble(edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble) DataSet(edu.cmu.tetrad.data.DataSet) ArrayList(java.util.ArrayList)

Example 37 with GeneralBootstrapTest

use of edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest in project tetrad by cmu-phil.

the class Cpc method search.

@Override
public Graph search(DataModel dataSet, Parameters parameters) {
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        if (algorithm != null) {
        // initialGraph = algorithm.search(dataSet, parameters);
        }
        edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(test.getTest(dataSet, parameters), initialGraph);
        search.setDepth(parameters.getInt("depth"));
        search.setKnowledge(knowledge);
        search.setFasRule(edu.cmu.tetrad.search.PcAll.FasRule.FAS);
        search.setColliderDiscovery(PcAll.ColliderDiscovery.CONSERVATIVE);
        search.setConflictRule(edu.cmu.tetrad.search.PcAll.ConflictRule.PRIORITY);
        search.setVerbose(parameters.getBoolean("verbose"));
        return search.search();
    } else {
        Cpc cpc = new Cpc(test, algorithm);
        // cpc.setKnowledge(knowledge);
        // if (initialGraph != null) {
        // cpc.setInitialGraph(initialGraph);
        // }
        DataSet data = (DataSet) dataSet;
        GeneralBootstrapTest search = new GeneralBootstrapTest(data, cpc, parameters.getInt("bootstrapSampleSize"));
        search.setKnowledge(knowledge);
        BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
        switch(parameters.getInt("bootstrapEnsemble", 1)) {
            case 0:
                edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
                break;
            case 1:
                edgeEnsemble = BootstrapEdgeEnsemble.Highest;
                break;
            case 2:
                edgeEnsemble = BootstrapEdgeEnsemble.Majority;
        }
        search.setEdgeEnsemble(edgeEnsemble);
        search.setParameters(parameters);
        search.setVerbose(parameters.getBoolean("verbose"));
        return search.search();
    }
}
Also used : GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) PcAll(edu.cmu.tetrad.search.PcAll) BootstrapEdgeEnsemble(edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble) DataSet(edu.cmu.tetrad.data.DataSet) PcAll(edu.cmu.tetrad.search.PcAll)

Example 38 with GeneralBootstrapTest

use of edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest in project tetrad by cmu-phil.

the class FAS method search.

@Override
public Graph search(DataModel dataSet, Parameters parameters) {
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        edu.cmu.tetrad.search.Fas search = new edu.cmu.tetrad.search.Fas(test.getTest(dataSet, parameters));
        search.setDepth(parameters.getInt("depth"));
        search.setKnowledge(knowledge);
        return search.search();
    } else {
        FAS algorithm = new FAS(test);
        // algorithm.setKnowledge(knowledge);
        DataSet data = (DataSet) dataSet;
        GeneralBootstrapTest search = new GeneralBootstrapTest(data, algorithm, parameters.getInt("bootstrapSampleSize"));
        search.setKnowledge(knowledge);
        BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
        switch(parameters.getInt("bootstrapEnsemble", 1)) {
            case 0:
                edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
                break;
            case 1:
                edgeEnsemble = BootstrapEdgeEnsemble.Highest;
                break;
            case 2:
                edgeEnsemble = BootstrapEdgeEnsemble.Majority;
        }
        search.setEdgeEnsemble(edgeEnsemble);
        search.setParameters(parameters);
        search.setVerbose(parameters.getBoolean("verbose"));
        return search.search();
    }
}
Also used : GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) BootstrapEdgeEnsemble(edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble) DataSet(edu.cmu.tetrad.data.DataSet)

Example 39 with GeneralBootstrapTest

use of edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest in project tetrad by cmu-phil.

the class FgesD method search.

@Override
public Graph search(DataModel dataSet, Parameters parameters) {
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        if (algorithm != null) {
        // initialGraph = algorithm.search(dataSet, parameters);
        }
        edu.cmu.tetrad.search.FgesD search;
        if (dataSet instanceof ICovarianceMatrix) {
            SemBicScoreDeterministic score = new SemBicScoreDeterministic((ICovarianceMatrix) dataSet);
            score.setPenaltyDiscount(parameters.getDouble("penaltyDiscount"));
            score.setDeterminismThreshold(parameters.getDouble("determinismThreshold"));
            search = new edu.cmu.tetrad.search.FgesD(score);
        } else if (dataSet instanceof DataSet) {
            SemBicScoreDeterministic score = new SemBicScoreDeterministic(new CovarianceMatrix((DataSet) dataSet));
            score.setPenaltyDiscount(parameters.getDouble("penaltyDiscount"));
            score.setDeterminismThreshold(parameters.getDouble("determinismThreshold"));
            search = new edu.cmu.tetrad.search.FgesD(score);
        } else {
            throw new IllegalArgumentException("Expecting a dataset or a covariance matrix.");
        }
        search.setFaithfulnessAssumed(parameters.getBoolean("faithfulnessAssumed"));
        search.setKnowledge(knowledge);
        search.setVerbose(parameters.getBoolean("verbose"));
        search.setMaxDegree(parameters.getInt("maxDegree"));
        // search.setSymmetricFirstStep(parameters.getBoolean("symmetricFirstStep"));
        Object obj = parameters.get("printStedu.cmream");
        if (obj instanceof PrintStream) {
            search.setOut((PrintStream) obj);
        }
        if (initialGraph != null) {
            search.setInitialGraph(initialGraph);
        }
        return search.search();
    } else {
        FgesD algorithm = new FgesD();
        // algorithm.setKnowledge(knowledge);
        if (initialGraph != null) {
            algorithm.setInitialGraph(initialGraph);
        }
        DataSet data = (DataSet) dataSet;
        GeneralBootstrapTest search = new GeneralBootstrapTest(data, algorithm, parameters.getInt("bootstrapSampleSize"));
        search.setKnowledge(knowledge);
        BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
        switch(parameters.getInt("bootstrapEnsemble", 1)) {
            case 0:
                edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
                break;
            case 1:
                edgeEnsemble = BootstrapEdgeEnsemble.Highest;
                break;
            case 2:
                edgeEnsemble = BootstrapEdgeEnsemble.Majority;
        }
        search.setEdgeEnsemble(edgeEnsemble);
        search.setParameters(parameters);
        search.setVerbose(parameters.getBoolean("verbose"));
        return search.search();
    }
}
Also used : PrintStream(java.io.PrintStream) SemBicScoreDeterministic(edu.cmu.tetrad.search.SemBicScoreDeterministic) GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) BootstrapEdgeEnsemble(edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble)

Example 40 with GeneralBootstrapTest

use of edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest in project tetrad by cmu-phil.

the class FasLofsConcatenated method search.

@Override
public Graph search(DataModel dataSet, Parameters parameters) {
    if (!parameters.getBoolean("bootstrapping")) {
        return search(Collections.singletonList((DataModel) DataUtils.getContinuousDataSet(dataSet)), parameters);
    } else {
        FasLofsConcatenated algorithm = new FasLofsConcatenated(rule);
        algorithm.setKnowledge(knowledge);
        List<DataSet> dataSets = Collections.singletonList(DataUtils.getContinuousDataSet(dataSet));
        GeneralBootstrapTest search = new GeneralBootstrapTest(dataSets, algorithm, parameters.getInt("bootstrapSampleSize"));
        BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
        switch(parameters.getInt("bootstrapEnsemble", 1)) {
            case 0:
                edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
                break;
            case 1:
                edgeEnsemble = BootstrapEdgeEnsemble.Highest;
                break;
            case 2:
                edgeEnsemble = BootstrapEdgeEnsemble.Majority;
        }
        search.setEdgeEnsemble(edgeEnsemble);
        search.setParameters(parameters);
        search.setVerbose(parameters.getBoolean("verbose"));
        return search.search();
    }
}
Also used : GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) BootstrapEdgeEnsemble(edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble)

Aggregations

GeneralBootstrapTest (edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)72 BootstrapEdgeEnsemble (edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble)66 DataSet (edu.cmu.tetrad.data.DataSet)32 Graph (edu.cmu.tetrad.graph.Graph)21 ArrayList (java.util.ArrayList)21 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)15 TakesInitialGraph (edu.cmu.tetrad.algcomparison.utils.TakesInitialGraph)10 Lofs2 (edu.cmu.tetrad.search.Lofs2)10 Node (edu.cmu.tetrad.graph.Node)6 Parameters (edu.cmu.tetrad.util.Parameters)6 PrintStream (java.io.PrintStream)6 Test (org.junit.Test)6 Algorithm (edu.cmu.tetrad.algcomparison.algorithm.Algorithm)5 PcAll (edu.cmu.tetrad.search.PcAll)5 Fges (edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Fges)4 IndependenceWrapper (edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper)4 ScoreWrapper (edu.cmu.tetrad.algcomparison.score.ScoreWrapper)4 edu.cmu.tetrad.search (edu.cmu.tetrad.search)4 DagToPag (edu.cmu.tetrad.search.DagToPag)4 IndTestScore (edu.cmu.tetrad.search.IndTestScore)4