Example usage for weka.classifiers.bayes NaiveBayesMultinomial NaiveBayesMultinomial

List of usage examples for weka.classifiers.bayes NaiveBayesMultinomial NaiveBayesMultinomial

Introduction

In this page you can find the example usage for weka.classifiers.bayes NaiveBayesMultinomial NaiveBayesMultinomial.

Prototype

NaiveBayesMultinomial

Source Link

Usage

From source file:at.aictopic1.sentimentanalysis.machinelearning.impl.NaiveBayesMultinomialClassifier.java

/**
 * sets classifier/*  w  w w.j a  v a  2 s  .com*/
 */
@Override
protected void setClassifier() {

    //classifier
    NaiveBayesMultinomial usedClassifier = new NaiveBayesMultinomial();
    //.. other options
    this.fcClassifier.setClassifier(usedClassifier);
}

From source file:Beans.Categorizer.java

public String newModel() throws SQLException, Exception {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    String BasePath = facesContext.getExternalContext().getRealPath("");
    File file = new File(BasePath + File.separator + "dataset/preprocessed.arff");

    /* This logic is to create the file if the
     * file is not already present//  w w  w.j  av a2s.c o  m
     */
    if (!file.exists()) {
        file.createNewFile();
    }

    //Here true is to append the content to file
    FileWriter fw = new FileWriter(file, true);
    //BufferedWriter writer give better performance
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write("'" + title + "','" + article + "','" + category + "'\n");
    //Closing BufferedWriter Stream
    bw.close();

    Instances processed_nom = test.ReadDataset(BasePath + File.separator + "dataset/preprocessed.arff");
    NaiveBayesMultinomial nBayes = new NaiveBayesMultinomial();
    test.CreateAndSaveModel(nBayes, processed_nom, BasePath + File.separator);

    title = "";
    article = "";
    category = "";
    part = null;
    return "added";
}