Examples of BayesNet


Examples of aima.core.probability.bayes.impl.BayesNet

            // cloudy
            0.29,
            // snow
            0.01 });

    return new BayesNet(cavity, weather);
  }
View Full Code Here

Examples of aima.core.probability.bayes.impl.BayesNet

            0.009986199723994478,
            // M=false, S=false
            0.9900138002760055

        }, meningitis);
    return new BayesNet(meningitis);
  }
View Full Code Here

Examples of aima.core.probability.bayes.impl.BayesNet

            // A=false, M=true
            0.01,
            // A=false, M=false
            0.99 }, alarm);

    return new BayesNet(burglary, earthquake);
  }
View Full Code Here

Examples of aima.core.probability.bayes.impl.BayesNet

            // Sprinkler=false, Rain=false, WetGrass=true
            0.0,
            // Sprinkler=false, Rain=false, WetGrass=false
            1.0 }, sprinkler, rain);

    return new BayesNet(cloudy);
  }
View Full Code Here

Examples of weka.classifiers.bayes.BayesNet

   *
   * @param data 
   * @return the bayes net
   */
  public BayesNet trainBayesNet(Instances data) {
      BayesNet cls = new BayesNet();
      try {
        String[] str = cls.getOptions();
     //   str[2] = "weka.classifiers.bayes.net.search.local.TAN";
     //   str[4] = "";
      //  str[5] = "";
        cls.setOptions(str);
      cls.buildClassifier(data);
    } catch (Exception e) {
      e.printStackTrace();
    }
   
    return cls;
View Full Code Here

Examples of weka.classifiers.bayes.BayesNet

    Instances data1 = wekaInter.getWekaDataFromUMatrix("Type", pars);
   
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // training
    wekaInter.saveWekaFile("world.arff", data1);
    BayesNet BN = wekaInter.trainBayesNet(data1);
    wekaInter.saveBIFFromFile("world.xml", BN);
  }
View Full Code Here

Examples of weka.classifiers.bayes.BayesNet

            }
        }
        // ok, now all data is binary, except the class attribute
        // now learn the empty and tree network

        BayesNet EmptyNet = new BayesNet();
        K2 oSearchAlgorithm = new K2();
        oSearchAlgorithm.setInitAsNaiveBayes(false);
        oSearchAlgorithm.setMaxNrOfParents(0);
        EmptyNet.setSearchAlgorithm(oSearchAlgorithm);
        EmptyNet.buildClassifier(instances);

        BayesNet NBNet = new BayesNet();
        oSearchAlgorithm.setInitAsNaiveBayes(true);
        oSearchAlgorithm.setMaxNrOfParents(1);
        NBNet.setSearchAlgorithm(oSearchAlgorithm);
        NBNet.buildClassifier(instances);

        // estimate CPTs
        for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
            if (iAttribute != instances.classIndex()) {
                  double w1 = 0.0, w2 = 0.0;
View Full Code Here

Examples of weka.classifiers.bayes.BayesNet

            if (bayesNet.getParentSet(iAttribute).getNrOfParents() > 1) {
                throw new Exception("Cannot handle networks with nodes with more than 1 parent (yet).");
            }
        }

        BayesNet EmptyNet = new BayesNet();
        K2 oSearchAlgorithm = new K2();
        oSearchAlgorithm.setInitAsNaiveBayes(false);
        oSearchAlgorithm.setMaxNrOfParents(0);
        EmptyNet.setSearchAlgorithm(oSearchAlgorithm);
        EmptyNet.buildClassifier(instances);

        BayesNet NBNet = new BayesNet();
        oSearchAlgorithm.setInitAsNaiveBayes(true);
        oSearchAlgorithm.setMaxNrOfParents(1);
        NBNet.setSearchAlgorithm(oSearchAlgorithm);
        NBNet.buildClassifier(instances);

        // estimate CPTs
        for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
            if (iAttribute != instances.classIndex()) {
                  double w1 = 0.0, w2 = 0.0;
View Full Code Here

Examples of weka.classifiers.bayes.BayesNet

    }
   
    m_random = new Random(m_nSeed);

    // keeps track of best structure found so far
    BayesNet bestBayesNet;
    // keeps track of score pf best structure found so far
    double fBestScore = calcScore(bayesNet)

    // initialize bestBayesNet
    bestBayesNet = new BayesNet();
    bestBayesNet.m_Instances = instances;
    bestBayesNet.initStructure();
    copyParentSets(bestBayesNet, bayesNet);
   
               
        // initialize population       
    BayesNetRepresentation  [] population = new BayesNetRepresentation [getPopulationSize()];
View Full Code Here

Examples of weka.classifiers.bayes.BayesNet

    // keeps track of score pf best structure found so far
    double fBestScore; 
    double fCurrentScore = calcScore(bayesNet);

    // keeps track of best structure found so far
    BayesNet bestBayesNet;

    // initialize bestBayesNet
    fBestScore = fCurrentScore;
    bestBayesNet = new BayesNet();
    bestBayesNet.m_Instances = instances;
    bestBayesNet.initStructure();
    copyParentSets(bestBayesNet, bayesNet);
   
               
        // go do the search       
        for (int iRun = 0; iRun < m_nRuns; iRun++) {
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.