Search in sources :

Example 1 with Fas

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

the class TestAutisticClassification method testForBiwei.

// @Test
public void testForBiwei() {
    Parameters parameters = new Parameters();
    parameters.set("penaltyDiscount", 2);
    parameters.set("depth", -1);
    parameters.set("numRuns", 10);
    parameters.set("randomSelectionSize", 1);
    parameters.set("Structure", "Placeholder");
    FaskGraphs files = new FaskGraphs("/Users/jdramsey/Downloads/USM_ABIDE", new Parameters());
    List<DataSet> datasets = files.getDatasets();
    List<String> filenames = files.getFilenames();
    for (int i = 0; i < datasets.size(); i++) {
        DataSet dataSet = datasets.get(i);
        SemBicScore score = new SemBicScore(new CovarianceMatrixOnTheFly(dataSet));
        Fas fas = new Fas(new IndTestScore(score));
        Graph graph = fas.search();
        System.out.println(graph);
        List<Node> nodes = graph.getNodes();
        StringBuilder b = new StringBuilder();
        for (int j = 0; j < nodes.size(); j++) {
            for (int k = 0; k < nodes.size(); k++) {
                if (graph.isAdjacentTo(nodes.get(j), nodes.get(k))) {
                    b.append("1 ");
                } else {
                    b.append("0 ");
                }
            }
            b.append("\n");
        }
        try {
            File dir = new File("/Users/jdramsey/Downloads/biwei/USM_ABIDE");
            dir.mkdirs();
            File file = new File(dir, filenames.get(i) + ".graph.txt");
            PrintStream out = new PrintStream(file);
            out.println(b);
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
Also used : PrintStream(java.io.PrintStream) Parameters(edu.cmu.tetrad.util.Parameters) DataSet(edu.cmu.tetrad.data.DataSet) IndTestScore(edu.cmu.tetrad.search.IndTestScore) Node(edu.cmu.tetrad.graph.Node) FileNotFoundException(java.io.FileNotFoundException) Graph(edu.cmu.tetrad.graph.Graph) Fas(edu.cmu.tetrad.search.Fas) CovarianceMatrixOnTheFly(edu.cmu.tetrad.data.CovarianceMatrixOnTheFly) File(java.io.File) SemBicScore(edu.cmu.tetrad.search.SemBicScore)

Aggregations

CovarianceMatrixOnTheFly (edu.cmu.tetrad.data.CovarianceMatrixOnTheFly)1 DataSet (edu.cmu.tetrad.data.DataSet)1 Graph (edu.cmu.tetrad.graph.Graph)1 Node (edu.cmu.tetrad.graph.Node)1 Fas (edu.cmu.tetrad.search.Fas)1 IndTestScore (edu.cmu.tetrad.search.IndTestScore)1 SemBicScore (edu.cmu.tetrad.search.SemBicScore)1 Parameters (edu.cmu.tetrad.util.Parameters)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PrintStream (java.io.PrintStream)1