Package weka.classifiers.bayes

Examples of weka.classifiers.bayes.NaiveBayesUpdateable


   * Train naive bayes.
   *
   * @param data
   */
  public void trainNaiveBayes(Instances data) {
      NaiveBayesUpdateable nb = new NaiveBayesUpdateable();
     
      try {
      nb.buildClassifier(data);
    } catch (Exception e) {
      e.printStackTrace();
    }
   
      for( int n = 0; n < data.size(); n++ ) {
           try {
        nb.updateClassifier(data.get(n));
      } catch (Exception e) {
        e.printStackTrace();
      }
      }

View Full Code Here


  disc.setInputFormat(trainingSets[i]);
  trainingSets[i] = Filter.useFilter(trainingSets[i], disc);

  trainingSets[i].randomize(r);
  trainingSets[i].stratify(5);
  NaiveBayesUpdateable fullModel = new NaiveBayesUpdateable();
  fullModel.buildClassifier(trainingSets[i]);

  // add the errors for this branch of the split
  m_errors += NBTreeNoSplit.crossValidate(fullModel, trainingSets[i], r);
      } else {
  // if fewer than min obj then just count them as errors
View Full Code Here

  disc.setInputFormat(trainingSets[i]);
  trainingSets[i] = Filter.useFilter(trainingSets[i], disc);

  trainingSets[i].randomize(r);
  trainingSets[i].stratify(5);
  NaiveBayesUpdateable fullModel = new NaiveBayesUpdateable();
  fullModel.buildClassifier(trainingSets[i]);

  // add the errors for this branch of the split
  m_errors += NBTreeNoSplit.crossValidate(fullModel, trainingSets[i], r);
      } else {
  for (int j = 0; j < trainingSets[i].numInstances(); j++) {
View Full Code Here

   *
   * @param instances an <code>Instances</code> value
   * @exception Exception if an error occurs
   */
  public final void buildClassifier(Instances instances) throws Exception {
    m_nb = new NaiveBayesUpdateable();
    m_disc = new Discretize();
    m_disc.setInputFormat(instances);
    Instances temp = Filter.useFilter(instances, m_disc);
    m_nb.buildClassifier(temp);
    if (temp.numInstances() >= 5) {
View Full Code Here

  disc.setInputFormat(trainingSets[i]);
  trainingSets[i] = Filter.useFilter(trainingSets[i], disc);

  trainingSets[i].randomize(r);
  trainingSets[i].stratify(5);
  NaiveBayesUpdateable fullModel = new NaiveBayesUpdateable();
  fullModel.buildClassifier(trainingSets[i]);

  // add the errors for this branch of the split
  m_errors += NBTreeNoSplit.crossValidate(fullModel, trainingSets[i], r);
      } else {
  // if fewer than min obj then just count them as errors
View Full Code Here

  disc.setInputFormat(trainingSets[i]);
  trainingSets[i] = Filter.useFilter(trainingSets[i], disc);

  trainingSets[i].randomize(r);
  trainingSets[i].stratify(5);
  NaiveBayesUpdateable fullModel = new NaiveBayesUpdateable();
  fullModel.buildClassifier(trainingSets[i]);

  // add the errors for this branch of the split
  m_errors += NBTreeNoSplit.crossValidate(fullModel, trainingSets[i], r);
      } else {
  for (int j = 0; j < trainingSets[i].numInstances(); j++) {
View Full Code Here

   *
   * @param instances an <code>Instances</code> value
   * @exception Exception if an error occurs
   */
  public final void buildClassifier(Instances instances) throws Exception {
    m_nb = new NaiveBayesUpdateable();
    m_disc = new Discretize();
    m_disc.setInputFormat(instances);
    Instances temp = Filter.useFilter(instances, m_disc);
    m_nb.buildClassifier(temp);
    if (temp.numInstances() >= 5) {
View Full Code Here

TOP

Related Classes of weka.classifiers.bayes.NaiveBayesUpdateable

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.