public StructEmBayesSearchRunner(
      DataWrapper dataWrapper, BayesImWrapper bayesImWrapper, StructEmBayesSearchParams params) {
    if (dataWrapper == null) {
      throw new NullPointerException();
    }

    if (bayesImWrapper == null) {
      throw new NullPointerException();
    }

    if (params == null) {
      throw new NullPointerException();
    }

    DataSet dataSet = (DataSet) dataWrapper.getSelectedDataModel();

    this.bayesPm = bayesImWrapper.getBayesIm().getBayesPm();

    FactoredBayesStructuralEM estimator = new FactoredBayesStructuralEM(dataSet, bayesPm);
    this.dataSet = estimator.getDataSet();

    try {
      this.estimatedBayesIm = estimator.maximization(params.getTolerance());
    } catch (IllegalArgumentException e) {
      throw new RuntimeException("Please specify the search tolerance first.");
    }
  }
Example #2
0
  public BayesImWrapper(BayesImWrapper bayesImWrapper) {
    if (bayesImWrapper == null) {
      throw new NullPointerException();
    }

    this.bayesIm = new MlBayesIm(bayesImWrapper.getBayesIm());
    log(bayesIm);
  }
Example #3
0
  public BayesImWrapper(
      BayesPmWrapper bayesPmWrapper, BayesImWrapper oldBayesImwrapper, BayesImParams params) {
    if (bayesPmWrapper == null) {
      throw new NullPointerException("BayesPmWrapper must not be null.");
    }

    if (params == null) {
      throw new NullPointerException("Params must not be null.");
    }

    BayesPm bayesPm = new BayesPm(bayesPmWrapper.getBayesPm());
    BayesIm oldBayesIm = oldBayesImwrapper.getBayesIm();

    if (params.getInitializationMode() == BayesImParams.MANUAL_RETAIN) {
      this.bayesIm = new MlBayesIm(bayesPm, oldBayesIm, MlBayesIm.MANUAL);
    } else if (params.getInitializationMode() == BayesImParams.RANDOM_RETAIN) {
      this.bayesIm = new MlBayesIm(bayesPm, oldBayesIm, MlBayesIm.RANDOM);
    } else if (params.getInitializationMode() == BayesImParams.RANDOM_OVERWRITE) {
      this.bayesIm = new MlBayesIm(bayesPm, MlBayesIm.RANDOM);
    }
    log(bayesIm);
  }
Example #4
0
 /**
  * Generates a simple exemplar of this class to test serialization.
  *
  * @see edu.cmu.TestSerialization
  * @see edu.cmu.tetradapp.util.TetradSerializableUtils
  */
 public static BayesImWrapperObs serializableInstance() {
   return new BayesImWrapperObs(BayesImWrapper.serializableInstance());
 }