Search in sources :

Example 41 with Parameters

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

the class TimeoutComparison method calcStatTables.

private double[][][] calcStatTables(double[][][][] allStats, Mode mode, int numTables, List<AlgorithmSimulationWrapper> wrappers, int numStats, Statistics statistics) {
    double[][][] statTables = new double[numTables][wrappers.size()][numStats + 1];
    for (int u = 0; u < numTables; u++) {
        for (int i = 0; i < wrappers.size(); i++) {
            for (int j = 0; j < numStats; j++) {
                if (statistics.getStatistics().get(j) instanceof ParameterColumn) {
                    String statName = statistics.getStatistics().get(j).getAbbreviation();
                    SimulationWrapper simulationWrapper = wrappers.get(i).getSimulationWrapper();
                    AlgorithmWrapper algorithmWrapper = wrappers.get(i).getAlgorithmWrapper();
                    double stat = Double.NaN;
                    List<String> parameterNames = simulationWrapper.getParameters();
                    Parameters parameters = simulationWrapper.getSimulationSpecificParameters();
                    for (String name : parameterNames) {
                        if (name.equals(statName)) {
                            if (parameters.get(name) instanceof Boolean) {
                                boolean b = parameters.getBoolean(name);
                                stat = b ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY;
                            } else {
                                stat = parameters.getDouble(name);
                            }
                            break;
                        }
                    }
                    if (Double.isNaN(stat)) {
                        List<String> _parameterNames = algorithmWrapper.getParameters();
                        Parameters _parameters = algorithmWrapper.parameters;
                        for (String name : _parameterNames) {
                            if (name.equals(statName)) {
                                try {
                                    stat = _parameters.getDouble(name);
                                } catch (Exception e) {
                                    boolean b = _parameters.getBoolean(name);
                                    stat = b ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY;
                                }
                                break;
                            }
                        }
                    }
                    statTables[u][i][j] = stat;
                } else if (mode == Mode.Average) {
                    statTables[u][i][j] = StatUtils.mean(allStats[u][i][j]);
                } else if (mode == Mode.WorstCase) {
                    statTables[u][i][j] = StatUtils.min(allStats[u][i][j]);
                } else if (mode == Mode.StandardDeviation) {
                    statTables[u][i][j] = StatUtils.sd(allStats[u][i][j]);
                } else {
                    throw new IllegalStateException();
                }
            }
        }
    }
    return statTables;
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) HasParameters(edu.cmu.tetrad.algcomparison.utils.HasParameters) TimeoutException(java.util.concurrent.TimeoutException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ParameterColumn(edu.cmu.tetrad.algcomparison.statistic.ParameterColumn)

Example 42 with Parameters

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

the class TestDataWrapper method testConstruction.

@Test
public void testConstruction() {
    this.dataWrapper = new DataWrapper(new Parameters());
    assertNotNull(dataWrapper);
}
Also used : DataWrapper(edu.cmu.tetradapp.model.DataWrapper) Parameters(edu.cmu.tetrad.util.Parameters) Test(org.junit.Test)

Example 43 with Parameters

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

the class TestDeltaTetradTest method getFigure4aSem.

private SemIm getFigure4aSem() {
    Graph graph = new EdgeListGraph();
    Node xi1 = new GraphNode("xi1");
    Node x1 = new GraphNode("x1");
    Node x2 = new GraphNode("x2");
    Node x3 = new GraphNode("x3");
    Node x4 = new GraphNode("x4");
    graph.addNode(xi1);
    graph.addNode(x1);
    graph.addNode(x2);
    graph.addNode(x3);
    graph.addNode(x4);
    graph.addDirectedEdge(xi1, x1);
    graph.addDirectedEdge(xi1, x2);
    graph.addDirectedEdge(xi1, x3);
    graph.addDirectedEdge(xi1, x4);
    SemPm pm = new SemPm(graph);
    Parameters params = new Parameters();
    return new SemIm(pm, params);
}
Also used : Parameters(edu.cmu.tetrad.util.Parameters) SemPm(edu.cmu.tetrad.sem.SemPm) SemIm(edu.cmu.tetrad.sem.SemIm)

Example 44 with Parameters

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

the class TestSimulatedFmri method testTough.

// @Test
public void testTough() {
    Parameters parameters = new Parameters();
    parameters.set("penaltyDiscount", 2);
    parameters.set("depth", 5);
    parameters.set("twoCycleAlpha", .01);
    parameters.set("numRuns", 1);
    parameters.set("randomSelectionSize", 10);
    parameters.set("Structure", "Placeholder");
    Statistics statistics = new Statistics();
    statistics.add(new ParameterColumn("Structure"));
    statistics.add(new AdjacencyPrecision());
    statistics.add(new AdjacencyRecall());
    statistics.add(new MathewsCorrAdj());
    statistics.add(new ArrowheadPrecision());
    statistics.add(new ArrowheadRecall());
    statistics.add(new TwoCyclePrecision());
    statistics.add(new TwoCycleRecall());
    statistics.add(new TwoCycleFalsePositive());
    statistics.add(new TwoCycleFalseNegative());
    statistics.add(new TwoCycleTruePositive());
    statistics.add(new ElapsedTime());
    statistics.setWeight("AP", 1.0);
    statistics.setWeight("AR", 1.0);
    statistics.setWeight("AHP", 1.0);
    statistics.setWeight("AHR", 1.0);
    statistics.setWeight("2CP", 1.0);
    statistics.setWeight("2CR", 1.0);
    statistics.setWeight("2CFP", 1.0);
    Simulations simulations = new Simulations();
    String dir = "/Users/jdramsey/Downloads/";
    String subdir = "data_fslfilter";
    simulations.add(new LoadContinuousDataAndSingleGraph(dir + "Markov_dist_thresh36", subdir));
    Algorithms algorithms = new Algorithms();
    // algorithms.add(new FasLofs(Lofs2.Rule.R1));
    // algorithms.add(new FasLofs(Lofs2.Rule.R2));
    // algorithms.add(new FasLofs(Lofs2.Rule.R3));
    // algorithms.add(new FasLofs(Lofs2.Rule.Patel));
    // algorithms.add(new FasLofs(Lofs2.Rule.Skew));
    // algorithms.add(new FasLofs(Lofs2.Rule.RSkew));
    // 
    // algorithms.add(new FgesConcatenated(new edu.cmu.tetrad.algcomparison.score.SemBicScore(), true));
    // algorithms.add(new PcStableMaxConcatenated(new SemBicTest(), true));
    algorithms.add(new FaskConcatenated(new SemBicScore()));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.R1));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.R2));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.R3));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.Patel));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.Skew));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.RSkew));
    Comparison comparison = new Comparison();
    comparison.setShowAlgorithmIndices(true);
    comparison.setShowSimulationIndices(true);
    comparison.setSortByUtility(false);
    comparison.setShowUtilities(false);
    comparison.setParallelized(false);
    comparison.setSaveGraphs(false);
    comparison.setTabDelimitedTables(false);
    comparison.compareFromSimulations("comparison", simulations, algorithms, statistics, parameters);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) Parameters(edu.cmu.tetrad.util.Parameters) Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) Comparison(edu.cmu.tetrad.algcomparison.Comparison) SemBicScore(edu.cmu.tetrad.algcomparison.score.SemBicScore)

Example 45 with Parameters

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

the class TestSimulatedFmri method task2.

// @Test
public void task2() {
    Parameters parameters = new Parameters();
    parameters.set("penaltyDiscount", 1);
    parameters.set("depth", -1);
    parameters.set("twoCycleAlpha", 0);
    parameters.set("faskDelta", -.1);
    parameters.set("numRuns", 10);
    parameters.set("randomSelectionSize", 2);
    parameters.set("Structure", "Placeholder");
    Statistics statistics = new Statistics();
    statistics.add(new ParameterColumn("Structure"));
    statistics.add(new AdjacencyPrecision());
    statistics.add(new AdjacencyRecall());
    // statistics.add(new MathewsCorrAdj());
    statistics.add(new ArrowheadPrecision());
    statistics.add(new ArrowheadRecall());
    statistics.add(new TwoCyclePrecision());
    statistics.add(new TwoCycleRecall());
    statistics.add(new TwoCycleFalsePositive());
    statistics.add(new TwoCycleFalseNegative());
    statistics.add(new TwoCycleTruePositive());
    statistics.add(new ElapsedTime());
    statistics.setWeight("AHR", 1.0);
    statistics.setWeight("2CP", 1.0);
    statistics.setWeight("2CR", 1.0);
    statistics.setWeight("2CFP", 1.0);
    Simulations simulations = new Simulations();
    Algorithms algorithms = new Algorithms();
    for (int i = 1; i <= 28; i++) {
        // if (i == 21) continue;
        simulations.add(new LoadContinuousDataSmithSim("/Users/user/Downloads/smithsim/", i));
    // simulations.add(new LoadContinuousDataPwdd7("/Users/user/Downloads/pwdd7/", i, "50_BOLDdemefilt1"));
    // simulations.add(new LoadContinuousDataPwdd7("/Users/user/Downloads/pwdd7/", i, "50_BOLDnoise"));
    }
    // algorithms.add(new LofsConcatenated(Lofs2.Rule.FASKLR));
    // algorithms.add(new LofsConcatenated(Lofs2.Rule.R1));
    // algorithms.add(new LofsConcatenated(Lofs2.Rule.R3));
    // algorithms.add(new LofsConcatenated(Lofs2.Rule.RSkew));
    // algorithms.add(new LofsConcatenated(Lofs2.Rule.RSkewE));
    // algorithms.add(new LofsConcatenated(Lofs2.Rule.Skew));
    // algorithms.add(new LofsConcatenated(Lofs2.Rule.SkewE));
    // algorithms.add(new LofsConcatenated(Lofs2.Rule.Patel));
    algorithms.add(new FaskConcatenated(new SemBicScore()));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.R1));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.R3));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.RSkew));
    // algorithms.add(new FasLofsConfcatenated(Lofs2.Rule.RSkewE));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.Skew));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.SkewE));
    // algorithms.add(new FasLofsConcatenated(Lofs2.Rule.Patel));
    Comparison comparison = new Comparison();
    comparison.setShowAlgorithmIndices(true);
    comparison.setShowSimulationIndices(true);
    comparison.setSortByUtility(false);
    comparison.setShowUtilities(false);
    comparison.setParallelized(false);
    comparison.setSaveGraphs(false);
    comparison.setTabDelimitedTables(false);
    comparison.setSaveGraphs(true);
    String directory = "smithsim";
    comparison.compareFromSimulations(directory, simulations, algorithms, statistics, parameters);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) Parameters(edu.cmu.tetrad.util.Parameters) Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) Comparison(edu.cmu.tetrad.algcomparison.Comparison) SemBicScore(edu.cmu.tetrad.algcomparison.score.SemBicScore)

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