Search in sources :

Example 1 with PcStableMax

use of edu.cmu.tetrad.search.PcStableMax in project tetrad by cmu-phil.

the class ImagesPcStableMax method search.

@Override
public Graph search(List<DataModel> dataModels, Parameters parameters) {
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        List<DataSet> dataSets = new ArrayList<>();
        for (DataModel dataModel : dataModels) {
            dataSets.add((DataSet) dataModel);
        }
        SemBicScoreImages3 score = new SemBicScoreImages3(dataSets);
        score.setPenaltyDiscount(parameters.getDouble("penaltyDiscount"));
        IndependenceTest test = new IndTestScore(score);
        PcStableMax search = new PcStableMax(test);
        search.setUseHeuristic(parameters.getBoolean("useMaxPOrientationHeuristic"));
        search.setMaxPathLength(parameters.getInt("maxPOrientationMaxPathLength"));
        search.setKnowledge(knowledge);
        search.setDepth(parameters.getInt("depth"));
        return search.search();
    } else {
        ImagesPcStableMax imagesPcStableMax = new ImagesPcStableMax();
        // imagesPcStableMax.setKnowledge(knowledge);
        List<DataSet> datasets = new ArrayList<>();
        for (DataModel dataModel : dataModels) {
            datasets.add((DataSet) dataModel);
        }
        GeneralBootstrapTest search = new GeneralBootstrapTest(datasets, imagesPcStableMax, 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 : IndependenceTest(edu.cmu.tetrad.search.IndependenceTest) GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) BootstrapEdgeEnsemble(edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble) IndTestScore(edu.cmu.tetrad.search.IndTestScore) ArrayList(java.util.ArrayList) PcStableMax(edu.cmu.tetrad.search.PcStableMax) SemBicScoreImages3(edu.cmu.tetrad.search.SemBicScoreImages3)

Example 2 with PcStableMax

use of edu.cmu.tetrad.search.PcStableMax in project tetrad by cmu-phil.

the class PcStableMaxConcatenated method search.

@Override
public Graph search(List<DataModel> dataModels, Parameters parameters) {
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        List<DataSet> dataSets = new ArrayList<>();
        for (DataModel dataModel : dataModels) {
            dataSets.add((DataSet) dataModel);
        }
        DataSet dataSet = DataUtils.concatenate(dataSets);
        PcStableMax search = new PcStableMax(test.getTest(dataSet, parameters));
        search.setUseHeuristic(parameters.getBoolean("useMaxPOrientationHeuristic"));
        search.setMaxPathLength(parameters.getInt("maxPOrientationMaxPathLength"));
        search.setKnowledge(knowledge);
        search.setDepth(parameters.getInt("depth"));
        return search.search();
    } else {
        PcStableMaxConcatenated pcStableMaxConcatenated = new PcStableMaxConcatenated(test, compareToTrue);
        // pcStableMaxConcatenated.setKnowledge(knowledge);
        List<DataSet> datasets = new ArrayList<>();
        for (DataModel dataModel : dataModels) {
            datasets.add((DataSet) dataModel);
        }
        GeneralBootstrapTest search = new GeneralBootstrapTest(datasets, pcStableMaxConcatenated, 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) ArrayList(java.util.ArrayList) PcStableMax(edu.cmu.tetrad.search.PcStableMax)

Aggregations

PcStableMax (edu.cmu.tetrad.search.PcStableMax)2 BootstrapEdgeEnsemble (edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble)2 GeneralBootstrapTest (edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)2 ArrayList (java.util.ArrayList)2 IndTestScore (edu.cmu.tetrad.search.IndTestScore)1 IndependenceTest (edu.cmu.tetrad.search.IndependenceTest)1 SemBicScoreImages3 (edu.cmu.tetrad.search.SemBicScoreImages3)1