use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class MbSearchEditor method getSearchParamBox.
private Box getSearchParamBox() {
if (!(getAlgorithmRunner().getParams() instanceof Parameters)) {
throw new IllegalStateException();
}
Box b = Box.createHorizontalBox();
Parameters params = getAlgorithmRunner().getParams();
MbSearchParamEditor comp = new MbSearchParamEditor();
comp.setParams(params);
comp.setParams(params);
comp.setup();
b.add(comp);
return b;
}
use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class PcGesSearchEditor method getToolbar.
/**
* Construct the toolbar panel.
*/
protected JPanel getToolbar() {
JPanel toolbar = new JPanel();
getExecuteButton().setText("Execute*");
getExecuteButton().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeStatsTabs();
execute();
}
});
JButton statsButton = new JButton("Calc Stats");
statsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Window owner = (Window) getTopLevelAncestor();
new WatchedProcess(owner) {
public void watch() {
calcStats();
}
};
}
});
Box b1 = Box.createVerticalBox();
b1.add(getParamsPanel());
b1.add(Box.createVerticalStrut(10));
Box b2 = Box.createHorizontalBox();
b2.add(Box.createGlue());
b2.add(getExecuteButton());
b1.add(b2);
b1.add(Box.createVerticalStrut(10));
if (getAlgorithmRunner().getDataModel() instanceof DataSet || getAlgorithmRunner().getDataModel() instanceof ICovarianceMatrix) {
Box b3 = Box.createHorizontalBox();
b3.add(Box.createGlue());
b3.add(statsButton);
b1.add(b3);
}
if (getAlgorithmRunner().getParams() instanceof Parameters) {
Parameters params = getAlgorithmRunner().getParams();
JCheckBox preventCycles = new JCheckBox("Aggressively Prevent Cycles");
preventCycles.setHorizontalTextPosition(AbstractButton.RIGHT);
preventCycles.setSelected(params.getBoolean("aggressivelyPreventCycles", false));
preventCycles.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JCheckBox box = (JCheckBox) e.getSource();
Parameters params = getAlgorithmRunner().getParams();
params.set("aggressivelyPreventCycles", box.isSelected());
}
});
b1.add(Box.createVerticalStrut(5));
Box hBox = Box.createHorizontalBox();
hBox.add(Box.createHorizontalGlue());
hBox.add(preventCycles);
b1.add(hBox);
b1.add(Box.createVerticalStrut(5));
}
Box b4 = Box.createHorizontalBox();
JLabel label = new JLabel("<html>" + "*Please note that some" + "<br>searches may take a" + "<br>long time to complete." + "</html>");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setVerticalAlignment(SwingConstants.CENTER);
label.setBorder(new TitledBorder(""));
b4.add(label);
b1.add(Box.createVerticalStrut(10));
b1.add(b4);
toolbar.add(b1);
return toolbar;
}
use of edu.cmu.tetrad.util.Parameters 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();
}
}
}
use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class TestAutisticClassification method testAutistic.
public void testAutistic() {
Parameters parameters = new Parameters();
parameters.set("penaltyDiscount", penaltyDiscount);
parameters.set("depth", depth);
parameters.set("twoCycleAlpha", 1e-5);
FaskGraphs train;
FaskGraphs test = null;
if (trainIndex == 1) {
train = new FaskGraphs("/Users/jdramsey/Documents/LAB_NOTEBOOK.2012.04.20/data/Joe_108_Variable", parameters, "ROI_data");
} else if (trainIndex == 2) {
train = new FaskGraphs("/Users/jdramsey/Documents/LAB_NOTEBOOK.2012.04.20/data/USM_Datasets2", parameters, "ROI_data");
} else if (trainIndex == 3) {
train = new FaskGraphs("/Users/jdramsey/Documents/LAB_NOTEBOOK.2012.04.20/data/Whole_Cerebellum_Scans", parameters, "ROI_data");
} else if (trainIndex == 4) {
train = new FaskGraphs("/Users/jdramsey/Downloads/USM_ABIDE", new Parameters());
} else {
throw new IllegalArgumentException("Type must be an index 1-4");
}
if (type == Type.TRAIN_TEST) {
if (testIndex == 1) {
test = new FaskGraphs("/Users/jdramsey/Documents/LAB_NOTEBOOK.2012.04.20/data/Joe_108_Variable", parameters, "ROI_data");
} else if (testIndex == 2) {
test = new FaskGraphs("/Users/jdramsey/Documents/LAB_NOTEBOOK.2012.04.20/data/USM_Datasets2", parameters, "ROI_data");
} else if (testIndex == 3) {
test = new FaskGraphs("/Users/jdramsey/Documents/LAB_NOTEBOOK.2012.04.20/data/Whole_Cerebellum_Scans", parameters, "ROI_data");
} else if (testIndex == 4) {
test = new FaskGraphs("/Users/jdramsey/Downloads/USM_ABIDE", new Parameters());
} else {
throw new IllegalArgumentException("Type must be an index 1-4");
}
train.reconcileNames(test);
test.reconcileNames(train);
}
if (type == Type.LEAVE_ONE_OUT) {
leaveOneOut(train);
} else if (type == Type.TRAIN_TEST) {
trainTest(train, test);
}
}
use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class TestConditionalGaussianSimulation method testBryan.
public void testBryan(String... args) {
Parameters parameters = new Parameters();
parameters.set("numCategoriesToDiscretize", 5);
parameters.set("numRuns", 10);
parameters.set("numMeasures", 100);
parameters.set("avgDegree", 2);
parameters.set("sampleSize", 10000);
parameters.set("minCategories", 2);
parameters.set("maxCategories", 5);
parameters.set("percentDiscrete", 50);
parameters.set("differentGraphs", true);
parameters.set("maxDegree", 5);
parameters.set("maxIndegree", 5);
parameters.set("maxOutdegree", 5);
parameters.set("structurePrior", 1);
parameters.set("fDegree", -1);
parameters.set("discretize", true);
// parameters.set("discretize", true, false);
Statistics statistics = new Statistics();
statistics.add(new AdjacencyPrecision());
statistics.add(new AdjacencyRecall());
statistics.add(new ArrowheadPrecision());
statistics.add(new ArrowheadRecall());
statistics.add(new ElapsedTime());
statistics.setWeight("AHP", 1.0);
statistics.setWeight("AHR", 1.0);
Algorithms algorithms = new Algorithms();
algorithms.add(new Fges(new ConditionalGaussianBicScore()));
Simulations simulations = new Simulations();
simulations.add(new ConditionalGaussianSimulation(new RandomForward()));
Comparison comparison = new Comparison();
comparison.setShowAlgorithmIndices(true);
comparison.setShowSimulationIndices(true);
comparison.setSortByUtility(true);
comparison.setShowUtilities(true);
comparison.setParallelized(false);
comparison.compareFromSimulations("comparison", simulations, algorithms, statistics, parameters);
}
Aggregations