Search in sources :

Example 11 with DataSet

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);
}
Also used : DataSet(edu.cmu.tetrad.data.DataSet)

Example 12 with DataSet

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;
}
Also used : DataSet(edu.cmu.tetrad.data.DataSet)

Example 13 with DataSet

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

Example 14 with DataSet

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)));
}
Also used : ContinuousVariable(edu.cmu.tetrad.data.ContinuousVariable) DiscreteVariable(edu.cmu.tetrad.data.DiscreteVariable) ColtDataSet(edu.cmu.tetrad.data.ColtDataSet) ColtDataSet(edu.cmu.tetrad.data.ColtDataSet) DataSet(edu.cmu.tetrad.data.DataSet) Node(edu.cmu.tetrad.graph.Node) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 15 with DataSet

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);
}
Also used : DiscreteVariable(edu.cmu.tetrad.data.DiscreteVariable) ColtDataSet(edu.cmu.tetrad.data.ColtDataSet) CellTable(edu.cmu.tetrad.data.CellTable) DataSet(edu.cmu.tetrad.data.DataSet) ColtDataSet(edu.cmu.tetrad.data.ColtDataSet) Node(edu.cmu.tetrad.graph.Node) LinkedList(java.util.LinkedList)

Aggregations

DataSet (edu.cmu.tetrad.data.DataSet)216 Test (org.junit.Test)65 Graph (edu.cmu.tetrad.graph.Graph)64 Node (edu.cmu.tetrad.graph.Node)60 ContinuousVariable (edu.cmu.tetrad.data.ContinuousVariable)48 ArrayList (java.util.ArrayList)45 ColtDataSet (edu.cmu.tetrad.data.ColtDataSet)36 GeneralBootstrapTest (edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)32 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)29 SemIm (edu.cmu.tetrad.sem.SemIm)28 SemPm (edu.cmu.tetrad.sem.SemPm)28 BootstrapEdgeEnsemble (edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble)26 DataModel (edu.cmu.tetrad.data.DataModel)22 Parameters (edu.cmu.tetrad.util.Parameters)22 DiscreteVariable (edu.cmu.tetrad.data.DiscreteVariable)20 File (java.io.File)16 ParseException (java.text.ParseException)16 LinkedList (java.util.LinkedList)14 ICovarianceMatrix (edu.cmu.tetrad.data.ICovarianceMatrix)13 DMSearch (edu.cmu.tetrad.search.DMSearch)10