Search in sources :

Example 1 with Fask

use of edu.cmu.tetrad.algcomparison.algorithm.multi.Fask in project tetrad by cmu-phil.

the class SpecialExampleSimulationClark method main.

public static void main(String... args) {
    Parameters parameters = new Parameters();
    parameters.set("numRuns", 20);
    parameters.set("sampleSize", 1000);
    parameters.set("twoCycleAlpha", 1);
    Statistics statistics = new Statistics();
    statistics.add(new AdjacencyPrecision());
    statistics.add(new AdjacencyRecall());
    statistics.add(new ArrowheadPrecision());
    statistics.add(new ArrowheadRecall());
    // statistics.add(new TwoCycleTruePositive());
    // statistics.add(new TwoCycleFalseNegative());
    // statistics.add(new TwoCycleFalsePositive());
    // For randomm forward graph
    parameters.set("numMeasures", 10);
    parameters.set("numLatents", 0);
    parameters.set("avgDegree", 2);
    parameters.set("maxDegree", 100);
    parameters.set("maxIndegree", 100);
    parameters.set("maxOutdegree", 100);
    parameters.set("connected", false);
    // 
    // statistics.setWeight("AP", 1.0);
    // statistics.setWeight("AR", 0.5);
    Algorithms algorithms = new Algorithms();
    algorithms.add(new Fask());
    Simulations simulations = new Simulations();
    // simulations.add(new SpecialDataClark(new SpecialGraphClark()));
    simulations.add(new SpecialDataClark(new RandomForward()));
    Comparison comparison = new Comparison();
    comparison.setShowAlgorithmIndices(true);
    comparison.setShowSimulationIndices(true);
    comparison.setSortByUtility(false);
    comparison.setShowUtilities(false);
    comparison.setParallelized(true);
    comparison.setSaveGraphs(true);
    comparison.setSavePatterns(true);
    comparison.setSavePags(true);
    // comparison.saveToFiles("comparison", new SpecialDataClark(new SpecialGraphClark()), parameters);
    comparison.compareFromSimulations("comparison", simulations, algorithms, statistics, parameters);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) Fask(edu.cmu.tetrad.algcomparison.algorithm.multi.Fask) Parameters(edu.cmu.tetrad.util.Parameters) Algorithms(edu.cmu.tetrad.algcomparison.algorithm.Algorithms) Comparison(edu.cmu.tetrad.algcomparison.Comparison) RandomForward(edu.cmu.tetrad.algcomparison.graph.RandomForward)

Example 2 with Fask

use of edu.cmu.tetrad.algcomparison.algorithm.multi.Fask in project tetrad by cmu-phil.

the class FaskGraphs method loadFiles.

private void loadFiles(String path, Parameters parameters, String... contains) {
    DataReader reader = new DataReader();
    reader.setVariablesSupplied(true);
    reader.setDelimiter(DelimiterType.TAB);
    File dir = new File(path);
    File[] files = dir.listFiles();
    if (files == null) {
        throw new NullPointerException();
    }
    FILE: for (File file : files) {
        String name = file.getName();
        for (String s : contains) {
            if (!name.contains(s))
                continue FILE;
        }
        if (!name.contains("graph")) {
            try {
                if (name.contains("autistic")) {
                    types.add(true);
                    DataSet dataSet = reader.parseTabular(new File(path, name));
                    filenames.add(name);
                    datasets.add(dataSet);
                    Fask fask = new Fask();
                    Graph search = fask.search(dataSet, parameters);
                    graphs.add(search);
                } else if (name.contains("typical")) {
                    types.add(false);
                    DataSet dataSet = reader.parseTabular(new File(path, name));
                    filenames.add(name);
                    datasets.add(dataSet);
                    Fask fask = new Fask();
                    Graph search = fask.search(dataSet, parameters);
                    graphs.add(search);
                }
                System.out.println("Loaded " + name);
            } catch (IOException e) {
                System.out.println("File " + name + " could not be parsed.");
            }
        }
    }
    reconcileNames();
}
Also used : DataReader(edu.cmu.tetrad.data.DataReader) Fask(edu.cmu.tetrad.algcomparison.algorithm.multi.Fask) Graph(edu.cmu.tetrad.graph.Graph) DataSet(edu.cmu.tetrad.data.DataSet) IOException(java.io.IOException) File(java.io.File)

Aggregations

Fask (edu.cmu.tetrad.algcomparison.algorithm.multi.Fask)2 Comparison (edu.cmu.tetrad.algcomparison.Comparison)1 Algorithms (edu.cmu.tetrad.algcomparison.algorithm.Algorithms)1 RandomForward (edu.cmu.tetrad.algcomparison.graph.RandomForward)1 Simulations (edu.cmu.tetrad.algcomparison.simulation.Simulations)1 DataReader (edu.cmu.tetrad.data.DataReader)1 DataSet (edu.cmu.tetrad.data.DataSet)1 Graph (edu.cmu.tetrad.graph.Graph)1 Parameters (edu.cmu.tetrad.util.Parameters)1 File (java.io.File)1 IOException (java.io.IOException)1