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();
}
}
}
Aggregations