Search in sources :

Example 31 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class TestDiscreteProbs method testCreateRandom.

public static void testCreateRandom() {
    DiscreteVariable x = new DiscreteVariable("X", 3);
    DiscreteVariable y = new DiscreteVariable("Y", 3);
    DiscreteVariable z = new DiscreteVariable("Z", 3);
    DiscreteVariable w = new DiscreteVariable("W", 2);
    List<Node> variables = new LinkedList<>();
    variables.add(x);
    variables.add(y);
    variables.add(z);
    variables.add(w);
    StoredCellProbs cellProbabilities = StoredCellProbs.createRandomCellTable(variables);
}
Also used : DiscreteVariable(edu.cmu.tetrad.data.DiscreteVariable) Node(edu.cmu.tetrad.graph.Node) LinkedList(java.util.LinkedList)

Example 32 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class SessionEditor method getSelectedModelComponents.

/**
 * @return a list of all the SessionNodeWrappers (TetradNodes) and
 * SessionNodeEdges that are model components for the respective
 * SessionNodes and SessionEdges selected in the workbench. Note that the
 * workbench, not the SessionEditorNodes themselves, keeps track of the
 * selection.
 */
public List getSelectedModelComponents() {
    List selectedComponents = getWorkbench().getSelectedComponents();
    List selectedModelComponents = new ArrayList();
    for (Object comp : selectedComponents) {
        if (comp instanceof SessionEditorNode) {
            SessionEditorNode editorNode = (SessionEditorNode) comp;
            Node modelNode = editorNode.getModelNode();
            selectedModelComponents.add(modelNode);
        } else if (comp instanceof SessionEditorEdge) {
            SessionEditorEdge editorEdge = (SessionEditorEdge) comp;
            Edge modelEdge = getWorkbench().getModelEdge(editorEdge);
            selectedModelComponents.add(modelEdge);
        }
    }
    return selectedModelComponents;
}
Also used : Node(edu.cmu.tetrad.graph.Node) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Edge(edu.cmu.tetrad.graph.Edge)

Example 33 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class ConstructTemplateAction method estimateFromSimulatedData.

private void estimateFromSimulatedData(int leftX) {
    SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
    SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
    SessionEditorWorkbench sessionWorkbench = sessionEditor.getSessionWorkbench();
    sessionWorkbench.deselectAll();
    List<Node> nodes = new LinkedList<>();
    String data = nextName("Data");
    String search = nextName("Search");
    nodes.add(addNode("Data", data, leftX, 100));
    nodes.add(addNode("Search", search, leftX + 150, 100));
    String graph = nextName("Graph");
    nodes.add(addNode("Graph", graph, leftX + 150, 200));
    String pm = nextName("PM");
    nodes.add(addNode("PM", pm, leftX + 150, 300));
    String estimator = nextName("Estimator");
    nodes.add(addNode("Estimator", estimator, leftX, 300));
    addEdge(data, search);
    addEdge(search, graph);
    addEdge(graph, pm);
    addEdge(data, estimator);
    addEdge(data, pm);
    addEdge(pm, estimator);
    selectSubgraph(nodes);
}
Also used : Node(edu.cmu.tetrad.graph.Node) SessionNode(edu.cmu.tetrad.session.SessionNode) SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef) LinkedList(java.util.LinkedList)

Example 34 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class ConstructTemplateAction method updateFromSimulatedData.

private void updateFromSimulatedData(int leftX) {
    SessionEditorIndirectRef sessionEditorRef = DesktopController.getInstance().getFrontmostSessionEditor();
    SessionEditor sessionEditor = (SessionEditor) sessionEditorRef;
    SessionEditorWorkbench sessionWorkbench = sessionEditor.getSessionWorkbench();
    sessionWorkbench.deselectAll();
    List<Node> nodes = new LinkedList<>();
    String data = nextName("Data");
    String search = nextName("Search");
    String estimator = nextName("Estimator");
    String updater = nextName("Updater");
    nodes.add(addNode("Data", data, leftX, 100));
    nodes.add(addNode("Search", search, 150 + leftX, 100));
    nodes.add(addNode("Estimator", estimator, 80 + leftX, 200));
    nodes.add(addNode("Updater", updater, 80 + leftX, 300));
    addEdge(data, search);
    addEdge(data, estimator);
    addEdge(search, estimator);
    addEdge(estimator, updater);
    selectSubgraph(nodes);
}
Also used : Node(edu.cmu.tetrad.graph.Node) SessionNode(edu.cmu.tetrad.session.SessionNode) SessionEditorIndirectRef(edu.cmu.tetradapp.util.SessionEditorIndirectRef) LinkedList(java.util.LinkedList)

Example 35 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class FgesMb method search.

@Override
public Graph search(DataModel dataSet, Parameters parameters) {
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        if (algorithm != null) {
        // initialGraph = algorithm.search(dataSet, parameters);
        }
        Score score = this.score.getScore(dataSet, parameters);
        edu.cmu.tetrad.search.FgesMb search = new edu.cmu.tetrad.search.FgesMb(score);
        search.setFaithfulnessAssumed(parameters.getBoolean("faithfulnessAssumed"));
        search.setKnowledge(knowledge);
        if (initialGraph != null) {
            search.setInitialGraph(initialGraph);
        }
        this.targetName = parameters.getString("targetName");
        Node target = this.score.getVariable(targetName);
        return search.search(Collections.singletonList(target));
    } else {
        FgesMb fgesMb = new FgesMb(score, algorithm);
        // fgesMb.setKnowledge(knowledge);
        if (initialGraph != null) {
            fgesMb.setInitialGraph(initialGraph);
        }
        DataSet data = (DataSet) dataSet;
        GeneralBootstrapTest search = new GeneralBootstrapTest(data, fgesMb, parameters.getInt("bootstrapSampleSize"));
        search.setKnowledge(knowledge);
        BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
        switch(parameters.getInt("bootstrapEnsemble", 1)) {
            case 0:
                edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
                break;
            case 1:
                edgeEnsemble = BootstrapEdgeEnsemble.Highest;
                break;
            case 2:
                edgeEnsemble = BootstrapEdgeEnsemble.Majority;
        }
        search.setEdgeEnsemble(edgeEnsemble);
        search.setParameters(parameters);
        search.setVerbose(parameters.getBoolean("verbose"));
        return search.search();
    }
}
Also used : Score(edu.cmu.tetrad.search.Score) GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) BootstrapEdgeEnsemble(edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble) Node(edu.cmu.tetrad.graph.Node)

Aggregations

Node (edu.cmu.tetrad.graph.Node)674 ArrayList (java.util.ArrayList)129 Graph (edu.cmu.tetrad.graph.Graph)106 GraphNode (edu.cmu.tetrad.graph.GraphNode)64 DataSet (edu.cmu.tetrad.data.DataSet)59 LinkedList (java.util.LinkedList)55 ContinuousVariable (edu.cmu.tetrad.data.ContinuousVariable)48 Test (org.junit.Test)48 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)46 List (java.util.List)45 Dag (edu.cmu.tetrad.graph.Dag)41 TetradMatrix (edu.cmu.tetrad.util.TetradMatrix)41 DiscreteVariable (edu.cmu.tetrad.data.DiscreteVariable)40 ChoiceGenerator (edu.cmu.tetrad.util.ChoiceGenerator)37 Endpoint (edu.cmu.tetrad.graph.Endpoint)29 DisplayNode (edu.cmu.tetradapp.workbench.DisplayNode)26 ColtDataSet (edu.cmu.tetrad.data.ColtDataSet)25 Edge (edu.cmu.tetrad.graph.Edge)23 SemIm (edu.cmu.tetrad.sem.SemIm)19 DepthChoiceGenerator (edu.cmu.tetrad.util.DepthChoiceGenerator)19