Search in sources :

Example 71 with Parameters

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

the class MimSearchEditor 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 BuildPureClustersIndTestParamsEditor(params, discrete);
        } else if (dataModel instanceof ICovarianceMatrix) {
            return new BuildPureClustersIndTestParamsEditor(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 IndTestParams: " + 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 72 with Parameters

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

the class PcStableLocalSearchEditor 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) {
        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;
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) WatchedProcess(edu.cmu.tetradapp.util.WatchedProcess) TitledBorder(javax.swing.border.TitledBorder)

Example 73 with Parameters

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

the class ExampleNonlinearSave method main.

public static void main(String... args) {
    Parameters parameters = new Parameters();
    parameters.set("numRuns", 100);
    parameters.set("numMeasures", 20);
    parameters.set("avgDegree", 3);
    parameters.set("sampleSize", 500);
    parameters.set("percentDiscrete", 0);
    parameters.set("minCategories", 2);
    parameters.set("maxCategories", 5);
    parameters.set("differentGraphs", true);
    parameters.set("interceptLow", 0);
    parameters.set("interceptHigh", 1);
    parameters.set("contiuousInfluence", 0.5);
    parameters.set("linearLow", 0.5);
    parameters.set("linearHigh", 1.0);
    parameters.set("quadraticLow", 0.5);
    parameters.set("quadraticHigh", 1.0);
    parameters.set("cubicLow", 0.2);
    parameters.set("cubicHigh", 0.3);
    parameters.set("varLow", 1);
    parameters.set("varHigh", 1);
    parameters.set("betaLow", 5);
    parameters.set("betaHigh", 8);
    parameters.set("gammaLow", 1.0);
    parameters.set("gammaHigh", 1.5);
    Simulation simulation = new LinearSineSimulation(new RandomForward());
    Comparison comparison = new Comparison();
    comparison.setShowAlgorithmIndices(true);
    comparison.saveToFiles("comparison", simulation, parameters);
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) Comparison(edu.cmu.tetrad.algcomparison.Comparison) RandomForward(edu.cmu.tetrad.algcomparison.graph.RandomForward)

Example 74 with Parameters

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

the class CompareExternalAlgorithms method main.

public static void main(String... args) {
    Parameters parameters = new Parameters();
    parameters.set("numRuns", 10);
    Statistics statistics = new Statistics();
    statistics.add(new ParameterColumn("numMeasures"));
    statistics.add(new ParameterColumn("avgDegree"));
    statistics.add(new ParameterColumn("sampleSize"));
    statistics.add(new AdjacencyPrecision());
    statistics.add(new AdjacencyRecall());
    statistics.add(new ArrowheadPrecision());
    statistics.add(new ArrowheadRecall());
    statistics.add(new F1Adj());
    statistics.add(new F1Arrow());
    statistics.add(new F1All());
    statistics.add(new ElapsedTime());
    statistics.setWeight("AP", 1.0);
    statistics.setWeight("AR", 0.5);
    statistics.setWeight("AHP", 1.0);
    statistics.setWeight("AHR", 0.5);
    Algorithms algorithms = new Algorithms();
    algorithms.add(new ExternalAlgorithmTetrad("PC_(\"Peter_and_Clark\"),_Priority_Rule,_using_Fisher_Z_test,_alpha_=_0.001"));
    algorithms.add(new ExternalAlgorithmPcalgPc("PC_pcalg_defaults_alpha_=_0.001"));
    algorithms.add(new ExternalAlgorithmBNTPc("learn_struct_pdag_pc_alpha_=_0.001"));
    Comparison comparison = new Comparison();
    comparison.setShowAlgorithmIndices(true);
    comparison.setShowSimulationIndices(true);
    comparison.setSortByUtility(false);
    comparison.setShowUtilities(false);
    comparison.setParallelized(false);
    comparison.generateReportFromExternalAlgorithms("/Users/user/comparison-data/condition_1", "/Users/user/causal-comparisons/condition_1", algorithms, statistics, parameters);
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) Comparison(edu.cmu.tetrad.algcomparison.Comparison) ExternalAlgorithmBNTPc(edu.cmu.tetrad.algcomparison.algorithm.external.ExternalAlgorithmBNTPc) ExternalAlgorithmPcalgPc(edu.cmu.tetrad.algcomparison.algorithm.external.ExternalAlgorithmPcalgPc) ExternalAlgorithmTetrad(edu.cmu.tetrad.algcomparison.algorithm.external.ExternalAlgorithmTetrad)

Example 75 with Parameters

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

the class FgesMbRunner method getIndependenceTest.

public IndependenceTest getIndependenceTest() {
    Object dataModel = getDataModel();
    if (dataModel == null) {
        dataModel = getSourceGraph();
    }
    Parameters params = getParams();
    IndTestType testType = (IndTestType) params.get("indTestType", IndTestType.FISHER_Z);
    return new IndTestChooser().getTest(dataModel, params, testType);
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters)

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