Пример #1
0
  @Override
  public Parameters getParameters() {
    Parameters parameters = super.getParameters();
    parameters.set(ParamAttrs.ALPHA, alpha);

    return parameters;
  }
Пример #2
0
  @Override
  public Graph search(DataSet dataSet, Parameters parameters) {
    edu.cmu.tetrad.search.Mbfs search =
        new edu.cmu.tetrad.search.Mbfs(
            test.getTest(dataSet, parameters), parameters.getInt("depth"));

    search.setKnowledge(knowledge);

    this.targetName = parameters.getString("targetName");
    Node target = dataSet.getVariable(targetName);
    return search.search(target);
  }
Пример #3
0
  public IndependenceTest getIndependenceTest() {
    Object dataModel = getDataModel();

    if (dataModel == null) {
      dataModel = getSourceGraph();
    }

    Parameters params = getParams();
    IndTestType testType;

    if (getParams() instanceof Parameters) {
      Parameters _params = params;
      testType = (IndTestType) _params.get("indTestType", IndTestType.FISHER_Z);
    } else {
      Parameters _params = params;
      testType = (IndTestType) _params.get("indTestType", IndTestType.FISHER_Z);
    }

    return new IndTestChooser().getTest(dataModel, params, testType);
  }
Пример #4
0
  /**
   * 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;

    Graph graph;

    IndependenceTest independenceTest = getIndependenceTest();
    Score score = new ScoredIndTest(independenceTest);

    if (independenceTest instanceof IndTestDSep) {
      final DagToPag dagToPag = new DagToPag(((IndTestDSep) independenceTest).getGraph());
      dagToPag.setCompleteRuleSetUsed(params.getBoolean("completeRuleSetUsed", false));
      graph = dagToPag.convert();
    } else {
      GFci fci = new GFci(independenceTest, score);
      fci.setKnowledge(knowledge);
      fci.setCompleteRuleSetUsed(params.getBoolean("completeRuleSetUsed", false));
      fci.setMaxPathLength(params.getInt("maxReachablePathLength", -1));
      fci.setMaxDegree(params.getInt("maxIndegree"));
      fci.setCompleteRuleSetUsed(false);
      fci.setFaithfulnessAssumed(params.getBoolean("faithfulnessAssumed", true));
      graph = fci.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);
  }
 @Override
 public edu.cmu.tetrad.search.IndependenceTest getTest(DataSet dataSet, Parameters parameters) {
   return new IndTestMultinomialLogisticRegressionWald(
       dataSet, parameters.getDouble("alpha"), false);
 }
  /**
   * Constructs the Gui used to edit properties; called from each constructor. Constructs labels and
   * text fields for editing each property and adds appropriate listeners.
   */
  public void setup() {
    setLayout(new BorderLayout());

    JRadioButton manualRetain = new JRadioButton();
    JRadioButton randomRetain = new JRadioButton();

    manualRetain.setText("Manually, retaining previous values where possible.");
    randomRetain.setText(
        "Using a symmetric prior for each row of each conditional" + " probability table.");

    ButtonGroup group = new ButtonGroup();
    group.add(manualRetain);
    group.add(randomRetain);

    final DoubleTextField symmetricAlphaField =
        new DoubleTextField(
            params.getDouble("symmetricAlpha", 1.0),
            5,
            NumberFormatUtil.getInstance().getNumberFormat());
    symmetricAlphaField.setFilter(
        new DoubleTextField.Filter() {
          public double filter(double value, double oldValue) {
            try {
              params.set("symmetricAlpha", value);
              return value;
            } catch (IllegalArgumentException e) {
              return oldValue;
            }
          }
        });

    if (getParams().getString("initializationMode", "manualRetain").equals("manualRetain")) {
      manualRetain.setSelected(true);
      symmetricAlphaField.setEnabled(false);
    } else if (getParams()
        .getString("initializationMode", "manualRetain")
        .equals("symmetricPrior")) {
      randomRetain.setSelected(true);
      symmetricAlphaField.setEnabled(true);
    } else {
      throw new IllegalStateException();
    }

    manualRetain.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            getParams().set("initializationMode", "manualRetain");
            symmetricAlphaField.setEnabled(false);
          }
        });

    randomRetain.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            getParams().set("initializationMode", "symmetricPrior");
            symmetricAlphaField.setEnabled(true);
          }
        });

    // continue workbench construction.
    Box b1 = Box.createVerticalBox();

    Box b2 = Box.createHorizontalBox();
    b2.add(new JLabel("Pseudocounts for this Dirichlet Bayes IM should be initialized:"));
    b2.add(Box.createHorizontalGlue());

    Box b3 = Box.createHorizontalBox();
    b3.add(manualRetain);
    b3.add(Box.createHorizontalGlue());

    Box b4 = Box.createHorizontalBox();
    b4.add(randomRetain);
    b4.add(Box.createHorizontalGlue());

    Box b5 = Box.createHorizontalBox();
    b5.add(Box.createRigidArea(new Dimension(30, 0)));
    b5.add(new JLabel("All pseudocounts = "));
    b5.add(symmetricAlphaField);
    b5.add(Box.createHorizontalGlue());

    b1.add(b2);
    b1.add(Box.createVerticalStrut(5));
    b1.add(b3);
    b1.add(b4);
    b1.add(b5);
    b1.add(Box.createHorizontalGlue());
    add(b1, BorderLayout.CENTER);
  }