List of usage examples for weka.classifiers.bayes NaiveBayesMultinomial NaiveBayesMultinomial
NaiveBayesMultinomial
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"; }