Esempio n. 1
0
 public void classify() {
   if (nb.isTrained()) {
     Features features = new Features(drawView.getPoints(), drawView.getStrokes());
     double predicted = nb.classifyInstance(features);
     resultText.setText(Integer.toString((int) predicted));
   } else {
     showAlertDialog("Bład", "Klasyfikator nie został wyuczony");
   }
 }
Esempio n. 2
0
 @Override
 public double[] getClassVotes(Instance inst, HoeffdingTree ht) {
   if (getWeightSeen() >= ((HoeffdingTreeNB) ht).nbThresholdOption.getValue()) {
     return NaiveBayes.doNaiveBayesPrediction(
         inst, this.observedClassDistribution, this.attributeObservers);
   }
   return super.getClassVotes(inst, ht);
 }
Esempio n. 3
0
 public void train() {
   try {
     File file = this.getFileStreamPath(dataTrainName);
     if (file.exists()) {
       InputStream inputStream = openFileInput(dataTrainName);
       DataCollection data = new DataCollection();
       data.build(inputStream);
       if (data.numberOfClasses() > 1) {
         nb.buildClassifier(data);
         showAlertDialog("Sukces", "Model został poprawnie wyuczony");
       } else {
         showAlertDialog("Bład", "Narysuj co najmniej dwie różne cyfry aby wyuczyć model");
       }
       inputStream.close();
     } else {
       showAlertDialog("Bład", "Brak pliku z danymi uczącymi");
     }
   } catch (Exception e) {
     Log.e("login activity", "Can not read file: " + e.toString());
   }
 }