Search in sources :

Example 1 with Parameters

use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.

the class MimbuildEditor method getIndTestParamBox.

/**
 * Factory to return the correct param editor for independence test params.
 * This will go in a little box in the search editor.
 */
private JComponent getIndTestParamBox(Parameters params) {
    if (params == null) {
        throw new NullPointerException();
    }
    if (params instanceof Parameters) {
        MimRunner runner = getMimRunner();
        params.set("varNames", runner.getParams().get("varNames", null));
        DataModel dataModel = runner.getData();
        if (dataModel instanceof DataSet) {
            DataSet data = (DataSet) runner.getData();
            boolean discrete = data.isDiscrete();
            return new BuildPureClustersIndTestParamsEditor2(params, discrete);
        } else if (dataModel instanceof ICovarianceMatrix) {
            return new BuildPureClustersIndTestParamsEditor2(params, false);
        }
    }
    if (params instanceof Parameters) {
        MimRunner runner = getMimRunner();
        params.set("varNames", runner.getParams().get("varNames", null));
        boolean discreteData = false;
        if (runner.getData() instanceof DataSet) {
            discreteData = ((DataSet) runner.getData()).isDiscrete();
        }
        return new PurifyIndTestParamsEditor(params, discreteData);
    }
    if (params instanceof Parameters) {
        MimRunner runner = getMimRunner();
        params.set("varNames", runner.getParams().get("varNames", null));
        return new MimBuildIndTestParamsEditor(params);
    }
    throw new IllegalArgumentException("Unrecognized Parameters: " + params.getClass());
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) DataSet(edu.cmu.tetrad.data.DataSet) DataModel(edu.cmu.tetrad.data.DataModel) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) MimRunner(edu.cmu.tetradapp.model.MimRunner)

Example 2 with Parameters

use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.

the class MimbuildEditor method getToolbar.

// ==============================PRIVATE METHODS=======================//
/**
 * Construct the toolbar panel.
 */
private JPanel getToolbar() {
    JPanel toolbar = new JPanel();
    getExecuteButton().setText("Execute*");
    getExecuteButton().addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            execute();
        }
    });
    JCheckBox showMaxP = new JCheckBox("Show Max P Value Result");
    showMaxP.setSelected(getMimRunner().getParams().getBoolean("showMaxP", false));
    showMaxP.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            boolean selected = box.isSelected();
            Parameters params = getMimRunner().getParams();
            params.set("showMaxP", selected);
            if (selected) {
                JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Only the graph with the highest P value will be shown, until deselected.");
            } else if (!selected) {
                JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Max P mode turned off and reset.");
                double maxP = -1;
                params.set("maxP", maxP);
                params.set("maxStructureGraph", (Graph) null);
            }
        }
    });
    JCheckBox include3Clusters = new JCheckBox("Include 3-clusters");
    include3Clusters.setSelected(getMimRunner().getParams().getBoolean("includeThreeClusters", true));
    include3Clusters.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            boolean selected = box.isSelected();
            getMimRunner().getParams().set("includeThreeClusters", selected);
        }
    });
    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);
    // 
    // Box b3 = 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(""));
    // b3.add(label);
    // b1.add(Box.createVerticalStrut(10));
    // b1.add(b3);
    b1.add(Box.createVerticalStrut(20));
    Box b4 = Box.createHorizontalBox();
    b4.add(showMaxP);
    b4.add(Box.createHorizontalGlue());
    b1.add(b4);
    Box b5 = Box.createHorizontalBox();
    b5.add(Box.createHorizontalStrut(25));
    b5.add(new JLabel("(Click to set/reset)"));
    b5.add(Box.createHorizontalGlue());
    b1.add(b5);
    b1.add(Box.createVerticalStrut(10));
    Box b6 = Box.createHorizontalBox();
    b6.add(include3Clusters);
    b6.add(Box.createHorizontalGlue());
    b1.add(b6);
    addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            if ("algorithmFinished".equals(evt.getPropertyName())) {
                specialToolbarSetup();
            }
        }
    });
    toolbar.add(b1);
    return toolbar;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Parameters(edu.cmu.tetrad.util.Parameters) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 3 with Parameters

use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.

the class LofsSearchEditorNew method getToolbar.

/**
 * Construct the toolbar panel.
 */
protected JPanel getToolbar() {
    final Parameters searchParams = getAlgorithmRunner().getParams();
    strongerDirection = new JCheckBox("Stronger Direction");
    strongerDirection.setSelected(searchParams.getBoolean("orientStrongerDirection", true));
    strongerDirection.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            JCheckBox button = (JCheckBox) actionEvent.getSource();
            searchParams.set("orientStrongerDirection", button.isSelected());
        }
    });
    selfLoopStrength = new DoubleTextField(searchParams.getDouble("selfLoopStrength", 0.0), 5, new DecimalFormat("0.0#####"));
    selfLoopStrength.setFilter(new DoubleTextField.Filter() {

        public double filter(double value, double oldValue) {
            searchParams.set("selfLoopStrength", value);
            return value;
        }
    });
    // selfLoopStrength.setSelected(searchParams.isMeanCenterResiduals());
    selfLoopStrength.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            JCheckBox checkBox = (JCheckBox) actionEvent.getSource();
            searchParams.set("meanCenterResiduals", checkBox.isSelected());
        }
    });
    JCheckBox orient2cycles = new JCheckBox("D");
    orient2cycles.setSelected(searchParams.getBoolean("r2Orient2Cycles", false));
    orient2cycles.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            JCheckBox checkBox = (JCheckBox) actionEvent.getSource();
            searchParams.set("r2Orient2Cycles", checkBox.isSelected());
        }
    });
    epsilon = new DoubleTextField(searchParams.getDouble("epsilon", .1), 5, new DecimalFormat("0.0#####"));
    epsilon.setFilter(new DoubleTextField.Filter() {

        public double filter(double value, double oldValue) {
            searchParams.set("epsilon", value);
            return value;
        }
    });
    zeta = new DoubleTextField(searchParams.getDouble("zeta", 1), 5, new DecimalFormat("0.0#####"));
    zeta.setFilter(new DoubleTextField.Filter() {

        public double filter(double value, double oldValue) {
            searchParams.set("dataSet", value);
            return value;
        }
    });
    label1 = new JLabel("Cutoff = ");
    label2 = new JLabel("Range = ");
    JPanel toolbar = new JPanel();
    getExecuteButton().setText("Execute*");
    getExecuteButton().addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            execute();
        }
    });
    JComboBox rulebox = new JComboBox();
    rulebox.addItem("R1");
    rulebox.addItem("R2");
    rulebox.addItem("R3");
    rulebox.addItem("R4");
    rulebox.addItem("EB");
    rulebox.addItem("Tanh");
    rulebox.addItem("Skew");
    rulebox.addItem("SkewE");
    rulebox.addItem("RSkew");
    rulebox.addItem("RSkewE");
    rulebox.addItem("Patel");
    // rulebox.addItem("IGCI");
    // rulebox.addItem("RC");
    // rulebox.addItem("Nlo");
    Lofs2.Rule _rule = (Lofs2.Rule) searchParams.get("rule", Lofs2.Rule.R3);
    disableR4Items();
    if (_rule == Lofs2.Rule.R1) {
        rulebox.setSelectedItem("R1");
    } else if (_rule == Lofs2.Rule.R1TimeLag) {
        rulebox.setSelectedItem("R1-TL");
    } else if (_rule == Lofs2.Rule.R2) {
        rulebox.setSelectedItem("R2");
    } else if (_rule == Lofs2.Rule.R3) {
        rulebox.setSelectedItem("R3");
    } else if (_rule == Lofs2.Rule.R4) {
        rulebox.setSelectedItem("R4");
        enableR4Items();
    } else if (_rule == Lofs2.Rule.Tanh) {
        rulebox.setSelectedItem("Tanh");
    } else if (_rule == Lofs2.Rule.Skew) {
        rulebox.setSelectedItem("Skew");
    } else if (_rule == Lofs2.Rule.SkewE) {
        rulebox.setSelectedItem("SkewE");
    } else if (_rule == Lofs2.Rule.RSkew) {
        rulebox.setSelectedItem("RSkew");
    } else if (_rule == Lofs2.Rule.RSkewE) {
        rulebox.setSelectedItem("RSkewE");
    } else if (_rule == Lofs2.Rule.Patel) {
        rulebox.setSelectedItem("Patel");
    } else if (_rule == Lofs2.Rule.FastICA) {
        rulebox.setSelectedItem("FastICA (see console)");
    } else if (_rule == Lofs2.Rule.Nlo) {
        rulebox.setSelectedItem("Nlo");
    // } else if (_rule == Lofs2.Rule.IGCI) {
    // rulebox.setSelectedItem("IGCI");
    // } else if (_rule == Lofs2.Rule.RC) {
    // rulebox.setSelectedItem("RC");
    }
    rulebox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            JComboBox box = (JComboBox) actionEvent.getSource();
            String item = (String) box.getSelectedItem();
            System.out.println(item);
            if ("R4".equals(item)) {
                enableR4Items();
            } else {
                disableR4Items();
            }
            if ("R1".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.R1);
            } else if ("R1-TL".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.R1TimeLag);
            } else if ("R2".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.R2);
            } else if ("R3".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.R3);
            } else if ("R4".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.R4);
            } else if ("EB".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.EB);
            } else if ("Tanh".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.Tanh);
            } else if ("Skew".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.Skew);
            } else if ("SkewE".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.SkewE);
            } else if ("RSkew".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.RSkew);
            } else if ("RSkewE".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.RSkewE);
            } else if ("Patel".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.Patel);
            } else if ("FastICA (see console)".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.FastICA);
            } else if ("Nlo".equals(item)) {
                searchParams.set("rule", Lofs2.Rule.Nlo);
            // } else if ("IGCI".equals(item)) {
            // searchParams.setRule(Lofs2.Rule.IGCI);
            // } else if ("RC".equals(item)) {
            // searchParams.setRule(Lofs2.Rule.RC);
            } else {
                throw new IllegalStateException();
            }
        }
    });
    JComboBox scoreBox = new JComboBox();
    scoreBox.addItem("Anderson Darling");
    scoreBox.addItem("Absolute Value");
    scoreBox.addItem("Log Cosh");
    // scoreBox.addItem("Maxent Approx");
    // scoreBox.addItem("Other");
    Lofs.Score _score = (Lofs.Score) searchParams.get("score", Lofs.Score.andersonDarling);
    if (_score == Lofs.Score.andersonDarling) {
        scoreBox.setSelectedItem("Anderson Darling");
    } else if (_score == Lofs.Score.skew) {
        scoreBox.setSelectedItem("Skew");
    } else if (_score == Lofs.Score.kurtosis) {
        scoreBox.setSelectedItem("Kurtosis");
    } else if (_score == Lofs.Score.entropy) {
        scoreBox.setSelectedItem("Entropy (delta = bins)");
    } else if (_score == Lofs.Score.fifthMoment) {
        scoreBox.setSelectedItem("Fifth Moment");
    } else if (_score == Lofs.Score.absoluteValue) {
        scoreBox.setSelectedItem("Absolute Value");
    } else if (_score == Lofs.Score.exp) {
        scoreBox.setSelectedItem("E(e^X)");
    } else if (_score == Lofs.Score.logcosh) {
        scoreBox.setSelectedItem("Log Cosh");
    } else if (_score == Lofs.Score.other) {
        scoreBox.setSelectedItem("Other");
    }
    scoreBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            JComboBox box = (JComboBox) actionEvent.getSource();
            String item = (String) box.getSelectedItem();
            System.out.println(item);
            if ("Anderson Darling".equals(item)) {
                searchParams.set("score", Lofs.Score.andersonDarling);
            } else if ("Skew".equals(item)) {
                searchParams.set("score", Lofs.Score.skew);
            } else if ("Kurtosis".equals(item)) {
                searchParams.set("score", Lofs.Score.kurtosis);
            } else if ("Fifth Moment".equals(item)) {
                searchParams.set("score", Lofs.Score.fifthMoment);
            } else if ("Entropy (delta = bins)".equals(item)) {
                searchParams.set("score", Lofs.Score.entropy);
            } else if ("Absolute Value".equals(item)) {
                searchParams.set("score", Lofs.Score.absoluteValue);
            } else if ("E(e^X)".equals(item)) {
                searchParams.set("score", Lofs.Score.exp);
            } else if ("Exp Unstandardized".equals(item)) {
                searchParams.set("score", Lofs.Score.expUnstandardized);
            } else if ("-e^(-X^2/2)".equals(item)) {
                searchParams.set("score", Lofs.Score.other);
            } else if ("Log Cosh".equals(item)) {
                searchParams.set("score", Lofs.Score.logcosh);
            } else if ("Maxent Approx".equals(item)) {
                searchParams.set("score", Lofs.Score.entropy);
            } else if ("Other".equals(item)) {
                searchParams.set("score", Lofs.Score.other);
            } else {
                throw new IllegalStateException();
            }
        }
    });
    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));
    Box b3b = Box.createHorizontalBox();
    b3b.add(new JLabel("Rule:"));
    b3b.add(Box.createHorizontalGlue());
    b3b.add(rulebox);
    b3b.add(Box.createHorizontalGlue());
    b1.add(b3b);
    Box b3c = Box.createHorizontalBox();
    b3c.add(strongerDirection);
    b3c.add(Box.createHorizontalGlue());
    b1.add(b3c);
    Box b3f = Box.createHorizontalBox();
    b3f.add(label1);
    b3f.add(epsilon);
    b3f.add(Box.createHorizontalGlue());
    b1.add(b3f);
    Box b3f3 = Box.createHorizontalBox();
    b3f3.add(label2);
    b3f3.add(zeta);
    b3f3.add(Box.createHorizontalGlue());
    b1.add(b3f3);
    Box b3e = Box.createHorizontalBox();
    b3e.add(new JLabel("SL coef = "));
    b3e.add(selfLoopStrength);
    b3e.add(Box.createHorizontalGlue());
    b1.add(b3e);
    Box b3g = Box.createHorizontalBox();
    b3g.add(new JLabel("Score:"));
    b3g.add(scoreBox);
    b3g.add(Box.createHorizontalGlue());
    b1.add(b3g);
    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;
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) DoubleTextField(edu.cmu.tetradapp.util.DoubleTextField) ActionEvent(java.awt.event.ActionEvent) DecimalFormat(java.text.DecimalFormat) TitledBorder(javax.swing.border.TitledBorder) ActionListener(java.awt.event.ActionListener)

Example 4 with Parameters

use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.

the class ScatterPlotDisplayPanelOld method paintComponent.

/**
 * Paints the histogram and related items.
 */
public void paintComponent(Graphics graphics) {
    double least = this.scatterPlot.getMinSample();
    double greatest = this.scatterPlot.getMaxSample();
    String minStr = format.format(least);
    String maxStr = format.format(greatest);
    Graphics2D g2d = (Graphics2D) graphics;
    FontMetrics fontMetrics = g2d.getFontMetrics();
    int widthMinStr = fontMetrics.stringWidth(minStr);
    int widthMaxStr = fontMetrics.stringWidth(maxStr);
    int maxWidth = Math.max(widthMinStr, widthMaxStr);
    PADDINGLEFT = maxWidth;
    PADDINGOTHER = 50;
    HEIGHT = 600 + PADDINGOTHER;
    WIDTH = 600 + PADDINGLEFT;
    SPACE = 2;
    DASH = 10;
    setSize(new Dimension(WIDTH + 2 * SPACE, HEIGHT));
    // set up variables.
    this.rectMap.clear();
    int height = HEIGHT - PADDINGOTHER;
    // draw background/surrounding box.
    g2d.setColor(this.getBackground());
    g2d.fillRect(0, 0, WIDTH + 2 * SPACE, HEIGHT);
    g2d.setColor(Color.WHITE);
    g2d.fillRect(PADDINGLEFT, 0, (WIDTH + SPACE) - PADDINGLEFT, height);
    // border
    g2d.setColor(LINE_COLOR);
    g2d.drawRect(PADDINGLEFT, 0, (WIDTH + SPACE) - PADDINGLEFT, height - 2 * SPACE);
    // draw the buttom line
    g2d.setColor(LINE_COLOR);
    // double least = Math.floor(this.scatterPlot.getMinSample());
    // double greatest = Math.ceil(this.scatterPlot.getMaxSample());
    g2d.drawString(minStr, PADDINGLEFT + 5, height + 15);
    g2d.drawLine(PADDINGLEFT, height + DASH, PADDINGOTHER, height);
    g2d.drawString(maxStr, WIDTH - widthMaxStr, height + 15);
    g2d.drawLine(WIDTH + SPACE, height + DASH, WIDTH + SPACE, height);
    // int size = (WIDTH - PADDINGLEFT) / 4;
    // draw the side line
    g2d.setColor(LINE_COLOR);
    int topY = 0;
    // String top = "" + Math.ceil(this.scatterPlot.getMaxSample());
    g2d.drawString(maxStr, PADDINGLEFT - fontMetrics.stringWidth(maxStr), topY + 10);
    g2d.drawLine(PADDINGLEFT - DASH, topY, PADDINGOTHER, topY);
    g2d.drawString(minStr, PADDINGLEFT - fontMetrics.stringWidth(minStr), height - 2);
    g2d.drawLine(PADDINGLEFT - DASH, height, PADDINGOTHER, height);
    // draw the origin lines if they should go on the screen -- first find out where they exist
    if (this.scatterPlot.getMinSample() < 0 && this.scatterPlot.getMaxSample() > 0) {
        double[] originLeft = plotPoint(least, 0, least, greatest);
        double[] originRight = plotPoint(greatest, 0, least, greatest);
        double[] originTop = plotPoint(0, least, least, greatest);
        double[] originBottom = plotPoint(0, greatest, least, greatest);
        g2d.drawLine((int) originLeft[0] + 2, (int) originLeft[1] + 2, (int) originRight[0] + 2, (int) originRight[1] + 2);
        g2d.drawLine((int) originTop[0] + 2, (int) originTop[1] + 2, (int) originBottom[0] + 2, (int) originBottom[1] + 2);
    }
    g2d.setColor(new Color(255, 0, 0));
    // draw each point in the indexSet from our ScatterPlot
    for (Object o : scatterPlot.getIndexSet()) {
        int i = (Integer) o;
        double x = this.scatterPlot.getxData()[i];
        double y = this.scatterPlot.getyData()[i];
        double[] result = plotPoint(x, y, least, greatest);
        g2d.fill(new Ellipse2D.Double(result[0], result[1], 4, 4));
    }
    // draw the regression line
    if (scatterPlot.isDrawRegLine()) {
        // RegressionRunner regRunner;
        RegressionDataset regData;
        /*
             * In the following code, the complement of the indexSet (for all integers <= (n - 1)) is
             * calculated.  This set of indices is removed from a copy of our original dataSet, such
             * that the ScatterPlot only contains the appropriate points for rendering.
             */
        Parameters params = new Parameters();
        Vector<String> regressors = new Vector();
        regressors.add(scatterPlot.getXVariable().getName());
        params.set("targetName", scatterPlot.getYVariable().getName());
        if (scatterPlot.getIndexSet().size() != scatterPlot.getDataSet().getNumRows()) {
            ColtDataSet newDataSet = new ColtDataSet((ColtDataSet) scatterPlot.getDataSet());
            int[] throwAway = new int[scatterPlot.getComplementIndexSet().size()];
            for (int j = 0; j < throwAway.length; j++) {
                throwAway[j] = (Integer) scatterPlot.getComplementIndexSet().get(j);
            }
            newDataSet.removeRows(throwAway);
            regData = new RegressionDataset(newDataSet);
        // regRunner = new RegressionRunner(new DataWrapper(newDataSet), params);
        } else {
            regData = new RegressionDataset(scatterPlot.getDataSet());
        // regRunner = new RegressionRunner(new DataWrapper(scatterPlot.dataSet), params);
        }
        // regRunner.execute();
        RegressionResult regResult = regData.regress(scatterPlot.getYVariable(), scatterPlot.getXVariable());
        double[] coef = regResult.getCoef();
        double[] regLeft = plotPoint(least, coef[0] + coef[1] * least, least, greatest);
        double[] regRight = plotPoint(greatest, coef[0] + coef[1] * greatest, least, greatest);
        g2d.setColor(LINE_COLOR);
        g2d.drawLine((int) regLeft[0] + 2, (int) regLeft[1] + 2, (int) regRight[0] + 2, (int) regRight[1] + 2);
    }
    // draw the display string.
    g2d.setColor(LINE_COLOR);
// g2d.drawString(getDisplayString(), PADDINGOTHER, HEIGHT - 5);
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) Ellipse2D(java.awt.geom.Ellipse2D) RegressionDataset(edu.cmu.tetrad.regression.RegressionDataset) ColtDataSet(edu.cmu.tetrad.data.ColtDataSet) Vector(java.util.Vector) RegressionResult(edu.cmu.tetrad.regression.RegressionResult)

Example 5 with Parameters

use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.

the class MimSearchEditor2 method getIndTestParamBox.

/**
 * Factory to return the correct param editor for independence test params.
 * This will go in a little box in the search editor.
 */
private JComponent getIndTestParamBox(Parameters params) {
    if (params == null) {
        throw new NullPointerException();
    }
    if (params instanceof Parameters) {
        MimRunner runner = getMimRunner();
        params.set("varNames", runner.getParams().get("varNames", null));
        DataModel dataModel = runner.getData();
        if (dataModel instanceof DataSet) {
            DataSet data = (DataSet) runner.getData();
            boolean discrete = data.isDiscrete();
            return new BuildPureClustersIndTestParamsEditor2(params, discrete);
        } else if (dataModel instanceof ICovarianceMatrix) {
            return new BuildPureClustersIndTestParamsEditor2(params, false);
        }
    }
    if (params instanceof Parameters) {
        MimRunner runner = getMimRunner();
        params.set("varNames", runner.getParams().get("varNames", null));
        boolean discreteData = false;
        if (runner.getData() instanceof DataSet) {
            discreteData = ((DataSet) runner.getData()).isDiscrete();
        }
        return new PurifyIndTestParamsEditor(params, discreteData);
    }
    if (params instanceof Parameters) {
        MimRunner runner = getMimRunner();
        params.set("varNames", runner.getParams().get("varNames", null));
        return new MimBuildIndTestParamsEditor(params);
    }
    throw new IllegalArgumentException("Unrecognized Parameters: " + params.getClass());
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) DataSet(edu.cmu.tetrad.data.DataSet) DataModel(edu.cmu.tetrad.data.DataModel) ICovarianceMatrix(edu.cmu.tetrad.data.ICovarianceMatrix) MimRunner(edu.cmu.tetradapp.model.MimRunner)

Aggregations

Parameters (edu.cmu.tetrad.util.Parameters)134 Comparison (edu.cmu.tetrad.algcomparison.Comparison)30 Graph (edu.cmu.tetrad.graph.Graph)26 Algorithms (edu.cmu.tetrad.algcomparison.algorithm.Algorithms)25 DataSet (edu.cmu.tetrad.data.DataSet)22 Knowledge2 (edu.cmu.tetrad.data.Knowledge2)20 IKnowledge (edu.cmu.tetrad.data.IKnowledge)18 Simulations (edu.cmu.tetrad.algcomparison.simulation.Simulations)17 RandomForward (edu.cmu.tetrad.algcomparison.graph.RandomForward)14 ArrayList (java.util.ArrayList)14 SemBicScore (edu.cmu.tetrad.algcomparison.score.SemBicScore)13 Test (org.junit.Test)13 Node (edu.cmu.tetrad.graph.Node)11 ActionEvent (java.awt.event.ActionEvent)10 ActionListener (java.awt.event.ActionListener)10 Algorithm (edu.cmu.tetrad.algcomparison.algorithm.Algorithm)8 Fges (edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Fges)8 DataModel (edu.cmu.tetrad.data.DataModel)8 TitledBorder (javax.swing.border.TitledBorder)8 FisherZ (edu.cmu.tetrad.algcomparison.independence.FisherZ)7