Package org.encog.ml.bayesian.query.enumerate

Examples of org.encog.ml.bayesian.query.enumerate.EnumerationQuery


    }
   
    network.finalizeStructure();
   
    //SamplingQuery query = new SamplingQuery(network);
    EnumerationQuery query = new EnumerationQuery(network);
   
    CalcProbability messageProbability = new CalcProbability(this.k);
    messageProbability.addClass(SPAM_DATA.length);
    messageProbability.addClass(HAM_DATA.length);
    double probSpam = messageProbability.calculate(0);

    spamEvent.getTable().addLine(probSpam, true);
    query.defineEventType(spamEvent, EventType.Outcome);
    query.setEventValue(spamEvent, true);
       
    index = 0;
    for( String word: words) {
      String word2 = word+index;
      BayesianEvent event = network.getEvent(word2);
      event.getTable().addLine(this.spamBag.probability(word), true, true); // spam
      event.getTable().addLine(this.hamBag.probability(word), true, false); // ham
      query.defineEventType(event, EventType.Evidence);
      query.setEventValue(event, true);
      index++;
    }

    //query.setSampleSize(100000000);
    query.execute();
    return query.getProbability();   
  }
View Full Code Here


   * The probabilities of each classification.
   */
  private double[] classificationProbabilities;

  public BayesianNetwork() {
    this.query = new EnumerationQuery(this);
  }
View Full Code Here

    // define query, if it exists
    if (queryType.length() > 0) {
      BayesianQuery query = null;
      if (queryType.equals("EnumerationQuery")) {
        query = new EnumerationQuery(result);
      } else {
        query = new SamplingQuery(result);
      }

      if (query != null && queryStr.length()>0) {
View Full Code Here

    a.getTable().addLine(0.5, true); // P(A) = 0.5
    b.getTable().addLine(0.2, true, true); // p(b|a) = 0.2
    b.getTable().addLine(0.8, true, false);// p(b|~a) = 0.8   
    network.validate();
   
    EnumerationQuery query = new EnumerationQuery(network);
    query.defineEventType(a, EventType.Evidence);
    query.defineEventType(b, EventType.Outcome);
    query.setEventValue(b, true);
    query.setEventValue(a, true);
    query.execute();
    testPercent(query.getProbability(),20);
  }
View Full Code Here

    x2.getTable().addLine(0.6, true, false);// p(x2|~a) = 0.6
    x3.getTable().addLine(0.2, true, true); // p(x3|a) = 0.2
    x3.getTable().addLine(0.6, true, false);// p(x3|~a) = 0.6
    network.validate();
   
    EnumerationQuery query = new EnumerationQuery(network);
    query.defineEventType(x1, EventType.Evidence);
    query.defineEventType(x2, EventType.Evidence);
    query.defineEventType(x3, EventType.Evidence);
    query.defineEventType(a, EventType.Outcome);
    query.setEventValue(a, true);
    query.setEventValue(x1, true);
    query.setEventValue(x2, true);
    query.setEventValue(x3, false);
    query.execute();
    testPercent(query.getProbability(),18);
  }
View Full Code Here

    x2.getTable().addLine(0.6, true, false);// p(x2|~a) = 0.6
    x3.getTable().addLine(0.2, true, true); // p(x3|a) = 0.2
    x3.getTable().addLine(0.6, true, false);// p(x3|~a) = 0.6
    network.validate();
   
    EnumerationQuery query = new EnumerationQuery(network);
    query.defineEventType(x1, EventType.Evidence);
    query.defineEventType(x3, EventType.Outcome);
    query.setEventValue(x1, true);
    query.setEventValue(x3, true);
    query.execute();
    testPercent(query.getProbability(),50);
  }
View Full Code Here

TOP

Related Classes of org.encog.ml.bayesian.query.enumerate.EnumerationQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.