use of edu.cmu.tetrad.data.DataSet in project tetrad by cmu-phil.
the class ScatterPlotAction method actionPerformed.
public void actionPerformed(ActionEvent e) {
DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel();
if (dataSet == null || dataSet.getNumColumns() == 0) {
JOptionPane.showMessageDialog(findOwner(), "Cannot display a scatter plot for an empty data set.");
return;
}
JPanel panel = new ScatterPlotView(dataSet);
EditorWindow editorWindow = new EditorWindow(panel, "Scatter Plots", "Save", true, dataEditor);
// JPanel dialog = createScatterPlotDialog(null, null);
// EditorWindow editorWindow = new EditorWindow(dialog, "Scatter Plots", "Save", true, dataEditor);
DesktopController.getInstance().addEditorWindow(editorWindow, JLayeredPane.PALETTE_LAYER);
editorWindow.pack();
editorWindow.setVisible(true);
}
use of edu.cmu.tetrad.data.DataSet in project tetrad by cmu-phil.
the class ScatterPlotAction method createScatterPlotDialog.
/**
* Creates a dialog that is showing the histogram for the given node (if null
* one is selected for you)
*/
private JPanel createScatterPlotDialog(ContinuousVariable yVariable, ContinuousVariable xVariable) {
String dialogTitle = "Scatter Plots";
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel();
ScatterPlotOld scatterPlot = new ScatterPlotOld(dataSet, yVariable, xVariable);
ScatterPlotEditorPanel editorPanel = new ScatterPlotEditorPanel(scatterPlot, dataSet);
ScatterPlotDisplayPanelOld display = new ScatterPlotDisplayPanelOld(scatterPlot);
editorPanel.addPropertyChangeListener(new ScatterPlotListener(display));
JMenuBar bar = new JMenuBar();
JMenu menu = new JMenu("File");
menu.add(new JMenuItem(new SaveComponentImage(display, "Save Scatter Plot")));
bar.add(menu);
Box box = Box.createHorizontalBox();
box.add(display);
box.add(Box.createHorizontalStrut(3));
box.add(editorPanel);
box.add(Box.createHorizontalStrut(5));
box.add(Box.createHorizontalGlue());
Box vBox = Box.createVerticalBox();
vBox.add(Box.createVerticalStrut(15));
vBox.add(box);
vBox.add(Box.createVerticalStrut(5));
panel.add(bar, BorderLayout.NORTH);
panel.add(vBox, BorderLayout.CENTER);
// return dialog;
return panel;
}
use of edu.cmu.tetrad.data.DataSet 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.data.DataSet in project tetrad by cmu-phil.
the class TestColtDataSet method testMixed.
@Test
public void testMixed() {
List<Node> variables = new LinkedList<>();
DiscreteVariable x1 = new DiscreteVariable("X1");
variables.add(x1);
ContinuousVariable x2 = new ContinuousVariable("X2");
variables.add(x2);
DataSet dataSet = new ColtDataSet(5, variables);
assertTrue(dataSet.getVariables().get(0) instanceof DiscreteVariable);
assertTrue(dataSet.getVariables().get(1) instanceof ContinuousVariable);
assertTrue(dataSet.getInt(0, 0) == -99);
assertTrue(Double.isNaN(dataSet.getDouble(1, 0)));
}
use of edu.cmu.tetrad.data.DataSet in project tetrad by cmu-phil.
the class TestCellTable method setUp.
public final void setUp() {
this.table = new CellTable(dims);
// // Add data to table.
List<Node> variables = new LinkedList<>();
variables.add(new DiscreteVariable("X1", 2));
variables.add(new DiscreteVariable("X2", 2));
variables.add(new DiscreteVariable("X3", 2));
variables.add(new DiscreteVariable("X4", 2));
DataSet dataSet = new ColtDataSet(data.length, variables);
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[0].length; j++) {
dataSet.setInt(i, j, data[i][j]);
}
}
int[] indices = new int[] { 0, 1, 2, 3 };
this.table.addToTable(dataSet, indices);
}
Aggregations