Tabnine Logo
NaiveBayes.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
weka.classifiers.bayes.NaiveBayes
constructor

Best Java code snippets using weka.classifiers.bayes.NaiveBayes.<init> (Showing top 20 results out of 315)

origin: stackoverflow.com

 Classifier cModel = (Classifier)new NaiveBayes();  
cModel.buildClassifier(isTrainingSet);  

weka.core.SerializationHelper.write("/some/where/nBayes.model", cModel);

Classifier cls = (Classifier) weka.core.SerializationHelper.read("/some/where/nBayes.model");

// Test the model
Evaluation eTest = new Evaluation(isTrainingSet);
eTest.evaluateModel(cls, isTrainingSet);
origin: nz.ac.waikato.cms.weka/distributedWekaBase

public AggregateableFilteredClassifier() {
 m_Classifier = new NaiveBayes();
}
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns the Capabilities of this filter.
 *
 * @return the capabilities of this object
 * @see Capabilities
 */
@Override
public Capabilities getCapabilities() {
 return new NaiveBayes().getCapabilities();
}
origin: nz.ac.waikato.cms.weka/weka-stable

 /**
  * Main method for testing this class.
  * 
  * @param argv the options
  */
 public static void main(String[] argv) {
  runClassifier(new NaiveBayes(), argv);
 }
}
origin: stackoverflow.com

 Classifier Mode; // a parent class
if(alg.equals("DecisionStump")) {
 Mode = new DecisionStump();
} else if(alg.equals("NaiveBayes")) {
 Mode = new NaiveBayes();
}
origin: Waikato/weka-trunk

/**
 * Returns the Capabilities of this filter.
 *
 * @return the capabilities of this object
 * @see Capabilities
 */
@Override
public Capabilities getCapabilities() {
 return new NaiveBayes().getCapabilities();
}
origin: Waikato/weka-trunk

 /**
  * Main method for testing this class.
  * 
  * @param argv the options
  */
 public static void main(String[] argv) {
  runClassifier(new NaiveBayes(), argv);
 }
}
origin: stackoverflow.com

Classifier mode
   if(alg.equals("DecisionStump"))
   {
     mode = new DecisionStump();
   }
   else if(alg.equals("NaiveBayes"))
   {
     mode = new NaiveBayes();
   }
origin: nz.ac.waikato.cms.weka/weka-stable

/** Creates a default NaiveBayes */
public Classifier getClassifier() {
 return new NaiveBayes();
}
origin: Waikato/weka-trunk

/** Creates a default NaiveBayes */
public Classifier getClassifier() {
 return new NaiveBayes();
}
origin: stackoverflow.com

 // Untested Java, I use Weka through JRuby
NaiveBayes naiveBayes = new NaiveBayes();
Remove remove = new Remove();
remove.setOptions(Utils.splitOptions("-R 1-2"));
FilteredClassifier model = new FilteredClassifier(naiveBayes, remove);

// Use model to classify as normal
origin: hltfbk/Excitement-Open-Platform

/**
 * Builds the classifier for the given training model
 */
private void initializeModel(CommonConfig config)
  throws ConfigurationException
{
  // Train the classifier
  logger.info("Training the classifier...");
  
  File arffFile = new File(modelDir + "/" + this.getClass().getSimpleName() + ".arff");
  
  classifier = new NaiveBayes();
  try {
    Instances data = DataSource.read(arffFile.getAbsolutePath());
    data.setClassIndex(data.numAttributes() - 1);
    
    classifier.buildClassifier(data);
  } catch (Exception e) {
    throw new ConfigurationException(e);
  }
}

origin: stackoverflow.com

 Classifier Clfs = null;

  try {
    if (modelType.equals("J48")) {
      Clfs = new J48();
    } else if (modelType.equals("MLP")) {
      Clfs = new MultilayerPerceptron(); 
    } else if (modelType.equals("IB3")) {
      Clfs = new IBk(3);
    } else if (modelType.equals("RF")) {
      Clfs = new RandomForest(); 
    } else if (modelType.equals("NB")) {
      Clfs = new NaiveBayes();
//...
origin: nz.ac.waikato.cms.weka/distributedWekaBase

protected WekaClassifierMapTask setupAggregateableBatchClassifier() {
 WekaClassifierMapTask task = new WekaClassifierMapTask();
 task.setClassifier(new weka.classifiers.bayes.NaiveBayes());
 return task;
}
origin: org.dkpro.similarity/dkpro-similarity-algorithms-ml-gpl

public static Classifier getClassifier(WekaClassifier classifier)
  throws IllegalArgumentException
{
  try {
    switch (classifier)
    {
      case NAIVE_BAYES:
        return new NaiveBayes();
      case J48:
        J48 j48 = new J48();			
        j48.setOptions(new String[] { "-C", "0.25", "-M", "2" });
        return j48;
      case SMO:
        SMO smo = new SMO();
        smo.setOptions(Utils.splitOptions("-C 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K \"weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0\""));
        return smo;
      case LOGISTIC:
        Logistic logistic = new Logistic();
        logistic.setOptions(Utils.splitOptions("-R 1.0E-8 -M -1"));
        return logistic;
      default:
        throw new IllegalArgumentException("Classifier " + classifier + " not found!");
    }
  }
  catch (Exception e) {
    throw new IllegalArgumentException(e);
  }
}

origin: de.tudarmstadt.ukp.similarity.algorithms/de.tudarmstadt.ukp.similarity.algorithms.ml-asl

public static Classifier getClassifier(WekaClassifier classifier)
  throws IllegalArgumentException
{
  try {
    switch (classifier)
    {
      case NAIVE_BAYES:
        return new NaiveBayes();
      case J48:
        J48 j48 = new J48();			
        j48.setOptions(new String[] { "-C", "0.25", "-M", "2" });
        return j48;
      case SMO:
        SMO smo = new SMO();
        smo.setOptions(Utils.splitOptions("-C 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K \"weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0\""));
        return smo;
      case LOGISTIC:
        Logistic logistic = new Logistic();
        logistic.setOptions(Utils.splitOptions("-R 1.0E-8 -M -1"));
        return logistic;
      default:
        throw new IllegalArgumentException("Classifier " + classifier + " not found!");
    }
  }
  catch (Exception e) {
    throw new IllegalArgumentException(e);
  }
}

origin: dkpro/dkpro-similarity

public static Classifier getClassifier(WekaClassifier classifier)
  throws IllegalArgumentException
{
  try {
    switch (classifier)
    {
      case NAIVE_BAYES:
        return new NaiveBayes();
      case J48:
        J48 j48 = new J48();			
        j48.setOptions(new String[] { "-C", "0.25", "-M", "2" });
        return j48;
      case SMO:
        SMO smo = new SMO();
        smo.setOptions(Utils.splitOptions("-C 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K \"weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0\""));
        return smo;
      case LOGISTIC:
        Logistic logistic = new Logistic();
        logistic.setOptions(Utils.splitOptions("-R 1.0E-8 -M -1"));
        return logistic;
      default:
        throw new IllegalArgumentException("Classifier " + classifier + " not found!");
    }
  }
  catch (Exception e) {
    throw new IllegalArgumentException(e);
  }
}

origin: nz.ac.waikato.cms.weka/distributedWekaBase

@Test
public void testScoreWithClassifier() throws Exception {
 Instances train = new Instances(new BufferedReader(new StringReader(
  CorrelationMatrixMapTaskTest.IRIS)));
 train.setClassIndex(train.numAttributes() - 1);
 NaiveBayes bayes = new NaiveBayes();
 bayes.buildClassifier(train);
 WekaScoringMapTask task = new WekaScoringMapTask();
 task.setModel(bayes, train, train);
 assertEquals(0, task.getMissingMismatchAttributeInfo().length());
 assertEquals(3, task.getPredictionLabels().size());
 for (int i = 0; i < train.numInstances(); i++) {
  assertEquals(3, task.processInstance(train.instance(i)).length);
 }
}
origin: stackoverflow.com

 public class Run {
  public static void main(String[] args) throws Exception {

    ConverterUtils.DataSource source1 = new ConverterUtils.DataSource("./data/train.arff");
    Instances train = source1.getDataSet();
    // setting class attribute if the data format does not provide this information
    // For example, the XRFF format saves the class attribute information as well
    if (train.classIndex() == -1)
      train.setClassIndex(train.numAttributes() - 1);

    ConverterUtils.DataSource source2 = new ConverterUtils.DataSource("./data/test.arff");
    Instances test = source2.getDataSet();
    // setting class attribute if the data format does not provide this information
    // For example, the XRFF format saves the class attribute information as well
    if (test.classIndex() == -1)
      test.setClassIndex(train.numAttributes() - 1);

    // model

    NaiveBayes naiveBayes = new NaiveBayes();
    naiveBayes.buildClassifier(train);

    // this does the trick  
    double label = naiveBayes.classifyInstance(test.instance(0));
    test.instance(0).setClassValue(label);

    System.out.println(test.instance(0).stringValue(4));
  }
}
origin: nz.ac.waikato.cms.weka/distributedWekaBase

@Test
public void testScoreWithClassifierSomeMissingFields() throws Exception {
 Instances train = new Instances(new BufferedReader(new StringReader(
  CorrelationMatrixMapTaskTest.IRIS)));
 train.setClassIndex(train.numAttributes() - 1);
 NaiveBayes bayes = new NaiveBayes();
 bayes.buildClassifier(train);
 WekaScoringMapTask task = new WekaScoringMapTask();
 Remove r = new Remove();
 r.setAttributeIndices("1");
 r.setInputFormat(train);
 Instances test = Filter.useFilter(train, r);
 task.setModel(bayes, train, test);
 assertTrue(task.getMissingMismatchAttributeInfo().length() > 0);
 assertTrue(task.getMissingMismatchAttributeInfo().equals(
  "sepallength missing from incoming data\n"));
 assertEquals(3, task.getPredictionLabels().size());
 for (int i = 0; i < test.numInstances(); i++) {
  assertEquals(3, task.processInstance(test.instance(i)).length);
 }
}
weka.classifiers.bayesNaiveBayes<init>

Popular methods of NaiveBayes

  • buildClassifier
    Generates the classifier.
  • updateClassifier
    Updates the classifier with the given instance.
  • getCapabilities
    Returns default capabilities of the classifier.
  • getConditionalEstimators
    Get all the conditional estimators.
  • getHeader
    Return the header that this classifier was trained with
  • getTechnicalInformation
    Returns an instance of a TechnicalInformation object, containing detailed information about the tech
  • getUseSupervisedDiscretization
    Get whether supervised discretization is to be used.
  • pad
  • runClassifier
  • setDisplayModelInOldFormat
    Set whether to display model output in the old, original format.
  • setUseKernelEstimator
    Sets if kernel estimator is to be used.
  • setUseSupervisedDiscretization
    Set whether supervised discretization is to be used.
  • setUseKernelEstimator,
  • setUseSupervisedDiscretization,
  • toStringOriginal,
  • classifyInstance,
  • distributionForInstance,
  • toString

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (Timer)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • BoxLayout (javax.swing)
  • Join (org.hibernate.mapping)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now