Skip to content

Commit

Permalink
Updated tetrad-lib test files
Browse files Browse the repository at this point in the history
  • Loading branch information
chirayukong committed Feb 15, 2017
1 parent 16c2bcc commit 847853c
Show file tree
Hide file tree
Showing 13 changed files with 402 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import edu.cmu.tetrad.graph.Graph;
import edu.cmu.tetrad.graph.GraphUtils;
import edu.cmu.tetrad.graph.Node;
import edu.cmu.tetrad.search.Fgs;
import edu.cmu.tetrad.search.Fges;
import edu.cmu.tetrad.search.SemBicScore;
import edu.cmu.tetrad.util.RandomUtil;
import edu.cmu.tetrad.util.TetradMatrix;
Expand Down Expand Up @@ -91,7 +91,7 @@ private List<List<Graph>> runAlgorithm(String path, List<List<DataSet>> allDatas

SemBicScore score = new SemBicScore(new CovarianceMatrixOnTheFly(dataSet));
score.setPenaltyDiscount(penaltyDiscount);
Fgs search = new Fgs(score);
Fges search = new Fges(score);
search.setVerbose(false);
Graph graph = search.search();
GraphUtils.saveGraph(graph, file, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
///////////////////////////////////////////////////////////////////////////////
// For information as to what this class does, see the Javadoc, below. //
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, //
// 2007, 2008, 2009, 2010, 2014, 2015 by Peter Spirtes, Richard Scheines, Joseph //
// Ramsey, and Clark Glymour. //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
///////////////////////////////////////////////////////////////////////////////

package edu.cmu.tetrad.test;

import edu.cmu.tetrad.algcomparison.Comparison;
import edu.cmu.tetrad.algcomparison.algorithm.Algorithms;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.*;
import edu.cmu.tetrad.algcomparison.graph.RandomForward;
import edu.cmu.tetrad.algcomparison.score.ConditionalGaussianBicScore;
import edu.cmu.tetrad.algcomparison.simulation.*;
import edu.cmu.tetrad.algcomparison.statistic.*;
import edu.cmu.tetrad.util.Parameters;

/**
* An example script to simulate data and run a comparison analysis on it.
*
* @author jdramsey
*/
public class TestConditionalGaussianSimulation {

public void test1() {
Parameters parameters = new Parameters();

parameters.set("numRuns", 1);
parameters.set("numMeasures", 100);
parameters.set("avgDegree", 4);
parameters.set("sampleSize", 1000);
parameters.set("penaltyDiscount", 2);

parameters.set("maxDegree", 8);

parameters.set("numCategories", 2, 3, 4, 5);
parameters.set("percentDiscrete", 50);

parameters.set("assumeMixed", false);

parameters.set("intervalBetweenRecordings", 20);

parameters.set("varLow", 1.);
parameters.set("varHigh", 3.);
parameters.set("coefLow", .5);
parameters.set("coefHigh", 1.5);
parameters.set("coefSymmetric", true);
parameters.set("meanLow", -1);
parameters.set("meanHigh", 1);

Statistics statistics = new Statistics();

statistics.add(new ParameterColumn("numCategories"));
statistics.add(new ParameterColumn("assumeMixed"));
statistics.add(new AdjacencyPrecision());
statistics.add(new AdjacencyRecall());
statistics.add(new ArrowheadPrecision());
statistics.add(new ArrowheadRecall());
statistics.add(new ElapsedTime());

statistics.setWeight("AP", 1.0);
statistics.setWeight("AR", 0.5);

Algorithms algorithms = new Algorithms();

algorithms.add(new Fges(new ConditionalGaussianBicScore()));
// algorithms.add(new PcMax(new ConditionalGaussianLRT()));

Simulations simulations = new Simulations();

simulations.add(new ConditionalGaussianSimulation(new RandomForward()));
// simulations.add(new LeeHastieSimulation(new RandomForward()));

Comparison comparison = new Comparison();

comparison.setShowAlgorithmIndices(true);
comparison.setShowSimulationIndices(false);
comparison.setSortByUtility(false);
comparison.setShowUtilities(false);
comparison.setParallelized(false);
comparison.setSaveGraphs(true);

comparison.setTabDelimitedTables(true);

comparison.compareFromSimulations("comparison", simulations, algorithms, statistics, parameters);
}

public static void main(String...args) {
new TestConditionalGaussianSimulation().test1();
}
}




This file was deleted.

4 changes: 2 additions & 2 deletions tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestDM.java
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public void test10() {

DMSearch search = new DMSearch();

search.setUseFgs(false);
search.setUseFges(false);

search.setInputs(new int[]{0, 1});
search.setOutputs(new int[]{2, 3, 4});
Expand Down Expand Up @@ -1206,7 +1206,7 @@ public DMSearch readAndSearchData(String fileLocation, int[] inputs, int[] outpu
if (useGES == false) {

search.setAlphaPC(.05);
search.setUseFgs(useGES);
search.setUseFges(useGES);

search.setData(data);
search.setTrueInputs(trueInputs);
Expand Down
Loading

0 comments on commit 847853c

Please sign in to comment.