Package weka.classifiers.bayes

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


    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

            }
        }
        // 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

            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

    }
   
    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

    // 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

    // 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

        // determine base scores
    double fCurrentScore = calcScore(bayesNet);

    // keep track of best scoring network
    double fBestScore = fCurrentScore;
    BayesNet bestBayesNet = new BayesNet();
    bestBayesNet.m_Instances = instances;
    bestBayesNet.initStructure();
    copyParentSets(bestBayesNet, bayesNet);

        double fTemp = m_fTStart;
        for (int iRun = 0; iRun < m_nRuns; iRun++) {
            boolean bRunSucces = false;
View Full Code Here

      fCurrentScore += fBaseScores[iAttribute];
        }

    // keep track of best scoring network
    double fBestScore = fCurrentScore;
    BayesNet bestBayesNet = new BayesNet();
    bestBayesNet.m_Instances = instances;
    bestBayesNet.initStructure();
    copyParentSets(bestBayesNet, bayesNet);

        double fTemp = m_fTStart;
        for (int iRun = 0; iRun < m_nRuns; iRun++) {
            boolean bRunSucces = false;
View Full Code Here

    }
   
    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 = 0.0
    for (int iAttribute = 0; iAttribute < instances.numAttributes(); iAttribute++) {
      fBestScore += calcNodeScore(iAttribute);
    }

    // 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

TOP

Related Classes of weka.classifiers.bayes.BayesNet

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.