Examples of BayesianNetwork


Examples of aima.core.probability.bayes.BayesianNetwork

public class PriorSampleTest {

  @Test
  public void testPriorSample_basic() {
    // AIMA3e pg. 530
    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    MockRandomizer r = new MockRandomizer(
        new double[] { 0.5, 0.5, 0.5, 0.5 });

    PriorSample ps = new PriorSample(r);
View Full Code Here

Examples of aima.core.probability.bayes.BayesianNetwork

  public static final double DELTA_THRESHOLD = ProbabilityModel.DEFAULT_ROUNDING_THRESHOLD;

  @Test
  public void testLikelihoodWeighting_basic() {
    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    AssignmentProposition[] e = new AssignmentProposition[] { new AssignmentProposition(
        ExampleRV.SPRINKLER_RV, Boolean.TRUE) };
    MockRandomizer r = new MockRandomizer(
        new double[] { 0.5, 0.5, 0.5, 0.5 });
View Full Code Here

Examples of aima.core.probability.bayes.BayesianNetwork

  @Test
  public void testLikelihoodWeighting_AIMA3e_pg533() {
    // AIMA3e pg. 533
    // <b>P</b>(Rain | Cloudy = true, WetGrass = true)
    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    AssignmentProposition[] e = new AssignmentProposition[] {
        new AssignmentProposition(ExampleRV.CLOUDY_RV, Boolean.TRUE),
        new AssignmentProposition(ExampleRV.WET_GRASS_RV, Boolean.TRUE) };
    // sample P(Sprinkler | Cloudy = true) = <0.1, 0.9>; suppose
View Full Code Here

Examples of aima.core.probability.bayes.BayesianNetwork

  public abstract void setUp();

  @Test
  public void testInferenceOnToothacheCavityCatchNetwork() {
    BayesianNetwork bn = BayesNetExampleFactory
        .constructToothacheCavityCatchNetwork();

    CategoricalDistribution d = bayesInference.ask(
        new RandomVariable[] { ExampleRV.CAVITY_RV },
        new AssignmentProposition[] {}, bn);
View Full Code Here

Examples of aima.core.probability.bayes.BayesianNetwork

        ProbabilityModel.DEFAULT_ROUNDING_THRESHOLD);
  }

  @Test
  public void testInferenceOnBurglaryAlarmNetwork() {
    BayesianNetwork bn = BayesNetExampleFactory
        .constructBurglaryAlarmNetwork();

    // AIMA3e. pg. 514
    CategoricalDistribution d = bayesInference
        .ask(new RandomVariable[] { ExampleRV.ALARM_RV },
View Full Code Here

Examples of aima.core.probability.bayes.BayesianNetwork

public class GibbsAskTest {
  public static final double DELTA_THRESHOLD = ProbabilityModel.DEFAULT_ROUNDING_THRESHOLD;

  @Test
  public void testGibbsAsk_basic() {
    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    AssignmentProposition[] e = new AssignmentProposition[] { new AssignmentProposition(
        ExampleRV.SPRINKLER_RV, Boolean.TRUE) };
    MockRandomizer r = new MockRandomizer(new double[] { 0.5, 0.5, 0.5,
        0.5, 0.5, 0.5, 0.6, 0.5, 0.5, 0.6, 0.5, 0.5 });
View Full Code Here

Examples of aima.core.probability.bayes.BayesianNetwork

  public static final double DELTA_THRESHOLD = ProbabilityModel.DEFAULT_ROUNDING_THRESHOLD;

  @Test
  public void testPriorSample_basic() {

    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    AssignmentProposition[] e = new AssignmentProposition[] { new AssignmentProposition(
        ExampleRV.SPRINKLER_RV, Boolean.TRUE) };
    MockRandomizer r = new MockRandomizer(new double[] { 0.1 });
    RejectionSampling rs = new RejectionSampling(new PriorSample(r));
View Full Code Here

Examples of aima.core.probability.bayes.BayesianNetwork

  @Test
  public void testRejectionSampling_AIMA3e_pg532() {
    // AIMA3e pg. 532

    BayesianNetwork bn = BayesNetExampleFactory
        .constructCloudySprinklerRainWetGrassNetwork();
    AssignmentProposition[] e = new AssignmentProposition[] { new AssignmentProposition(
        ExampleRV.SPRINKLER_RV, Boolean.TRUE) };

    // 400 required as 4 variables and 100 samples planned
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianNetwork

  }
 
  public double probabilitySpam(String m) {
    List<String> words = separateSpaces(m);
   
    BayesianNetwork network = new BayesianNetwork();
    BayesianEvent spamEvent = network.createEvent("spam");
   
    int index = 0;
    for( String word: words) {
      BayesianEvent event = network.createEvent(word+index);
      network.createDependency(spamEvent, event);
      index++;
    }
   
    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++;
View Full Code Here

Examples of org.encog.ml.bayesian.BayesianNetwork

  /**
   * Constructor.
   */
  public BIFHandler() {
    this.network = new BayesianNetwork();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.