Search in sources :

Example 51 with Knowledge2

use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.

the class PcStableRunner method execute.

// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    int depth = getParams().getInt("depth", -1);
    PcStable pc = new PcStable(getIndependenceTest());
    pc.setKnowledge(knowledge);
    pc.setAggressivelyPreventCycles(isAggressivelyPreventCycles());
    pc.setDepth(depth);
    pc.setInitialGraph(initialGraph);
    Graph graph = pc.search();
    System.out.println(graph);
    if (getSourceGraph() != null) {
        GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
    } else if (knowledge.isDefaultToKnowledgeLayout()) {
        SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
    } else {
        GraphUtils.circleLayout(graph, 200, 200, 150);
    }
    setResultGraph(graph);
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 52 with Knowledge2

use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.

the class CcdRunner method execute.

// =================PUBLIC METHODS OVERRIDING ABSTRACT=================//
/**
 * Executes the algorithm, producing (at least) a result workbench. Must be
 * implemented in the extending class.
 */
public void execute() {
    Ccd ccd = new Ccd(getIndependenceTest());
    ccd.setDepth(getParams().getInt("depth", -1));
    ccd.setKnowledge((IKnowledge) getParams().get("knowledge", new Knowledge2()));
    Graph graph = ccd.search();
    setResultGraph(graph);
    if (getSourceGraph() != null) {
        GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
    } else {
        GraphUtils.circleLayout(graph, 200, 200, 150);
    }
}
Also used : Graph(edu.cmu.tetrad.graph.Graph) Ccd(edu.cmu.tetrad.search.Ccd) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 53 with Knowledge2

use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.

the class YeastPcCcdSearchWrapper method main.

public static void main(String[] args) {
    int[][] yeastReg = { { 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0 }, { 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0 }, { 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1 }, { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1 }, { 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 }, { 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1 }, { 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 }, { 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, { 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1 } };
    List listOfNames = new ArrayList();
    // get the file containing the file names
    DataSet cds = null;
    try {
        DataReader reader = new DataReader();
        cds = reader.parseTabular(new File(args[0]));
    } catch (IOException e) {
        e.printStackTrace();
    }
    String outfileprefix = args[1];
    String outverbosefile = outfileprefix + ".doc";
    String outsummaryfile = outfileprefix + ".xls";
    OutputStream s1 = null;
    OutputStream s2 = null;
    boolean verbose = true;
    try {
        s1 = new FileOutputStream(outverbosefile);
    } catch (IOException e) {
        System.out.println("Cannot open file file " + outverbosefile);
        System.exit(0);
    }
    DataOutputStream d1 = new DataOutputStream(s1);
    try {
        s2 = new FileOutputStream(outsummaryfile);
    } catch (IOException e) {
        System.out.println("Cannot open file file " + outsummaryfile);
        System.exit(0);
    }
    DataOutputStream d2 = new DataOutputStream(s2);
    try {
        // if(!verbose) {
        d2.writeBytes("File\tPC05 FP\tPC05 FN\tPC10 FP\tPC10 FN\tPC15 FP\t");
        d2.writeBytes("PC15 FN\tPC20 FP\tPC20 FN\tPC30 FP\tPC30 FN\t");
        d2.writeBytes("CCD05 FP\tCCD05 FN\tCCD10 FP\tCCD10 FN\tCCD 15 FP\t");
        d2.writeBytes("CCD15 FN\tCCD20 FP\tCCD20 FN\tCCD30 FP\tCCD 30 FN\n");
        // }
        // read in variable name and set up DataSet.
        // RectangularDataSet dataSet = DataLoaders.loadContinuousData(
        // new File(args[0]), DelimiterType.WHITESPACE,
        // "//"
        // );
        // int ngenes = 6;
        int ngenes = Integer.valueOf(args[2]);
        IKnowledge bk = new Knowledge2();
        bk.addToTiersByVarNames(listOfNames);
        // if(verbose) {
        d1.writeBytes("\n \n**Results for data in file yeastTRN**\n \n");
        d1.writeBytes("  Acutal adj matrix: \n");
        printAdjMatrix(yeastReg, listOfNames, d1);
        // }
        int[] PC05Accuracy;
        PC05Accuracy = PCAccuracy(0.05, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] PC10Accuracy;
        PC10Accuracy = PCAccuracy(0.10, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] PC15Accuracy;
        PC15Accuracy = PCAccuracy(0.15, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] PC20Accuracy;
        PC20Accuracy = PCAccuracy(0.20, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] PC30Accuracy;
        PC30Accuracy = PCAccuracy(0.30, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] CCD05Accuracy;
        CCD05Accuracy = CcdAccuracy(0.05, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] CCD10Accuracy;
        CCD10Accuracy = CcdAccuracy(0.10, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] CCD15Accuracy;
        CCD15Accuracy = CcdAccuracy(0.15, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] CCD20Accuracy;
        CCD20Accuracy = CcdAccuracy(0.20, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        int[] CCD30Accuracy;
        CCD30Accuracy = CcdAccuracy(0.30, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);
        /*
            int[] FCI05Accuracy;
            FCI05Accuracy =
              FCIAccuracy(0.05, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);

            int[] FCI10Accuracy;
            FCI10Accuracy =
              FCIAccuracy(0.10, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);

            int[] FCI15Accuracy;
            FCI15Accuracy =
              FCIAccuracy(0.15, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);

            int[] FCI20Accuracy;
            FCI20Accuracy =
              FCIAccuracy(0.20, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);

            int[] FCI30Accuracy;
            FCI30Accuracy =
              FCIAccuracy(0.30, ngenes, cds, bk, yeastReg, listOfNames, d1, verbose);


            */
        // if(!verbose) {
        d2.writeBytes("yeastTRN \t");
        d2.writeBytes(PC05Accuracy[0] + "\t");
        d2.writeBytes(PC05Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(PC10Accuracy[0] + "\t");
        d2.writeBytes(PC10Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(PC15Accuracy[0] + "\t");
        d2.writeBytes(PC15Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(PC20Accuracy[0] + "\t");
        d2.writeBytes(PC20Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(PC30Accuracy[0] + "\t");
        d2.writeBytes(PC30Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(CCD05Accuracy[0] + "\t");
        d2.writeBytes(CCD05Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(CCD10Accuracy[0] + "\t");
        d2.writeBytes(CCD10Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(CCD15Accuracy[0] + "\t");
        d2.writeBytes(CCD15Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(CCD20Accuracy[0] + "\t");
        d2.writeBytes(CCD20Accuracy[1] + "\t");
        // }
        // if(!verbose) {
        d2.writeBytes(CCD30Accuracy[0] + "\t");
        d2.writeBytes(CCD30Accuracy[1] + "\n");
    // }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DataSet(edu.cmu.tetrad.data.DataSet) ArrayList(java.util.ArrayList) Knowledge2(edu.cmu.tetrad.data.Knowledge2) IKnowledge(edu.cmu.tetrad.data.IKnowledge) DataReader(edu.cmu.tetrad.data.DataReader) List(java.util.List) ArrayList(java.util.ArrayList)

Example 54 with Knowledge2

use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.

the class MbUtils method doAbbreviatedMbOrientation.

/**
 * A reiteration of orientation steps 5-7 of the search for use in generating the list of MB DAGs.
 */
private static void doAbbreviatedMbOrientation(Graph graph, IndependenceTest test, int depth, Node target) {
    SearchGraphUtils.orientUsingMeekRulesLocally(new Knowledge2(), graph, test, depth);
    trimToMbNodes(graph, target, false);
    trimEdgesAmongParents(graph, target);
    trimEdgesAmongParentsOfChildren(graph, target);
}
Also used : Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 55 with Knowledge2

use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.

the class CfciRunner method execute.

// =================PUBLIC METHODS OVERRIDING ABSTRACT=================//
/**
 * Executes the algorithm, producing (at least) a result workbench. Must be
 * implemented in the extending class.
 */
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    Parameters searchParams = getParams();
    Parameters params = searchParams;
    Cfci cfci = new Cfci(getIndependenceTest());
    cfci.setKnowledge(knowledge);
    cfci.setDepth(params.getInt("depth", -1));
    Graph graph = cfci.search();
    if (getSourceGraph() != null) {
        GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
    } else if (knowledge.isDefaultToKnowledgeLayout()) {
        SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
    } else {
        GraphUtils.circleLayout(graph, 200, 200, 150);
    }
    setResultGraph(graph);
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Parameters(edu.cmu.tetrad.util.Parameters) Knowledge2(edu.cmu.tetrad.data.Knowledge2) Cfci(edu.cmu.tetrad.search.Cfci)

Aggregations

Knowledge2 (edu.cmu.tetrad.data.Knowledge2)75 IKnowledge (edu.cmu.tetrad.data.IKnowledge)43 Parameters (edu.cmu.tetrad.util.Parameters)17 Graph (edu.cmu.tetrad.graph.Graph)13 GraphWorkbench (edu.cmu.tetradapp.workbench.GraphWorkbench)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)5 DataSet (edu.cmu.tetrad.data.DataSet)4 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)4 MeekRules (edu.cmu.tetrad.search.MeekRules)4 WatchedProcess (edu.cmu.tetradapp.util.WatchedProcess)4 CharArrayWriter (java.io.CharArrayWriter)4 PrintWriter (java.io.PrintWriter)4 ContinuousVariable (edu.cmu.tetrad.data.ContinuousVariable)3 Node (edu.cmu.tetrad.graph.Node)3 CovarianceMatrixOnTheFly (edu.cmu.tetrad.data.CovarianceMatrixOnTheFly)1 DataModel (edu.cmu.tetrad.data.DataModel)1 DataReader (edu.cmu.tetrad.data.DataReader)1 KnowledgeEdge (edu.cmu.tetrad.data.KnowledgeEdge)1 Edge (edu.cmu.tetrad.graph.Edge)1