Search in sources :

Example 1 with SemBicScoreImages

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

the class TsImages method search.

@Override
public Graph search(List<DataModel> dataSets, Parameters parameters) {
    List<DataModel> dataModels = new ArrayList<>();
    for (DataModel dataSet : dataSets) {
        dataModels.add(dataSet);
    }
    TsGFci search;
    if (score instanceof SemBicScore) {
        SemBicScoreImages gesScore = new SemBicScoreImages(dataModels);
        gesScore.setPenaltyDiscount(parameters.getDouble("penaltyDiscount"));
        IndependenceTest test = new IndTestScore(gesScore);
        search = new TsGFci(test, gesScore);
    } else if (score instanceof BdeuScore) {
        double samplePrior = parameters.getDouble("samplePrior", 1);
        double structurePrior = parameters.getDouble("structurePrior", 1);
        BdeuScoreImages score = new BdeuScoreImages(dataModels);
        score.setSamplePrior(samplePrior);
        score.setStructurePrior(structurePrior);
        IndependenceTest test = new IndTestScore(score);
        search = new TsGFci(test, score);
    } else {
        throw new IllegalStateException("Sorry, data must either be all continuous or all discrete.");
    }
    IKnowledge knowledge = dataModels.get(0).getKnowledge();
    search.setKnowledge(knowledge);
    return search.search();
}
Also used : BdeuScoreImages(edu.cmu.tetrad.search.BdeuScoreImages) IKnowledge(edu.cmu.tetrad.data.IKnowledge) IndependenceTest(edu.cmu.tetrad.search.IndependenceTest) SemBicScoreImages(edu.cmu.tetrad.search.SemBicScoreImages) DataModel(edu.cmu.tetrad.data.DataModel) IndTestScore(edu.cmu.tetrad.search.IndTestScore) BdeuScore(edu.cmu.tetrad.algcomparison.score.BdeuScore) ArrayList(java.util.ArrayList) TsGFci(edu.cmu.tetrad.search.TsGFci) SemBicScore(edu.cmu.tetrad.algcomparison.score.SemBicScore)

Example 2 with SemBicScoreImages

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

the class ImagesSemBic method search.

@Override
public Graph search(List<DataModel> dataSets, Parameters parameters) {
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        final SemBicScoreImages score = new SemBicScoreImages(dataSets);
        score.setPenaltyDiscount(parameters.getDouble("penaltyDiscount"));
        edu.cmu.tetrad.search.Fges search = new edu.cmu.tetrad.search.Fges(score);
        search.setKnowledge(knowledge);
        return search.search();
    } else {
        ImagesSemBic imagesSemBic = new ImagesSemBic();
        // imagesSemBic.setKnowledge(knowledge);
        List<DataSet> datasets = new ArrayList<>();
        for (DataModel dataModel : dataSets) {
            datasets.add((DataSet) dataModel);
        }
        GeneralBootstrapTest search = new GeneralBootstrapTest(datasets, imagesSemBic, 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) Fges(edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Fges) SemBicScoreImages(edu.cmu.tetrad.search.SemBicScoreImages)

Example 3 with SemBicScoreImages

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

the class TsImagesSemBic 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);
        }
        edu.cmu.tetrad.search.TsGFci search = new edu.cmu.tetrad.search.TsGFci(new IndTestScore(new SemBicScoreImages(dataModels)), new SemBicScoreImages(dataModels));
        search.setFaithfulnessAssumed(true);
        search.setKnowledge(knowledge);
        return search.search();
    } else {
        TsImagesSemBic tsImagesSemBic = new TsImagesSemBic();
        // tsImagesSemBic.setKnowledge(knowledge);
        List<DataSet> datasets = new ArrayList<>();
        for (DataModel dataModel : dataModels) {
            datasets.add((DataSet) dataModel);
        }
        GeneralBootstrapTest search = new GeneralBootstrapTest(datasets, tsImagesSemBic, 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) IndTestScore(edu.cmu.tetrad.search.IndTestScore) ArrayList(java.util.ArrayList) SemBicScoreImages(edu.cmu.tetrad.search.SemBicScoreImages)

Aggregations

SemBicScoreImages (edu.cmu.tetrad.search.SemBicScoreImages)3 ArrayList (java.util.ArrayList)3 IndTestScore (edu.cmu.tetrad.search.IndTestScore)2 BootstrapEdgeEnsemble (edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble)2 GeneralBootstrapTest (edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)2 Fges (edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Fges)1 BdeuScore (edu.cmu.tetrad.algcomparison.score.BdeuScore)1 SemBicScore (edu.cmu.tetrad.algcomparison.score.SemBicScore)1 DataModel (edu.cmu.tetrad.data.DataModel)1 IKnowledge (edu.cmu.tetrad.data.IKnowledge)1 BdeuScoreImages (edu.cmu.tetrad.search.BdeuScoreImages)1 IndependenceTest (edu.cmu.tetrad.search.IndependenceTest)1 TsGFci (edu.cmu.tetrad.search.TsGFci)1