Search in sources :

Example 1 with MlBayesEstimator

use of edu.cmu.tetrad.bayes.MlBayesEstimator in project tetrad by cmu-phil.

the class BayesEstimatorWrapper method estimate.

private void estimate(DataSet dataSet, BayesPm bayesPm) {
    Graph graph = bayesPm.getDag();
    for (Object o : graph.getNodes()) {
        Node node = (Node) o;
        if (node.getNodeType() == NodeType.LATENT) {
            throw new IllegalArgumentException("Estimation of Bayes IM's " + "with latents is not supported.");
        }
    }
    if (DataUtils.containsMissingValue(dataSet)) {
        throw new IllegalArgumentException("Please remove or impute missing values.");
    }
    try {
        MlBayesEstimator estimator = new MlBayesEstimator();
        this.bayesIm = estimator.estimate(bayesPm, dataSet);
    } catch (ArrayIndexOutOfBoundsException e) {
        e.printStackTrace();
        throw new RuntimeException("Value assignments between Bayes PM " + "and discrete data set do not match.");
    }
}
Also used : Graph(edu.cmu.tetrad.graph.Graph) Node(edu.cmu.tetrad.graph.Node) MlBayesEstimator(edu.cmu.tetrad.bayes.MlBayesEstimator)

Aggregations

MlBayesEstimator (edu.cmu.tetrad.bayes.MlBayesEstimator)1 Graph (edu.cmu.tetrad.graph.Graph)1 Node (edu.cmu.tetrad.graph.Node)1