jncc20
Class NaiveBayes

java.lang.Object
  extended by jncc20.NaiveClassifier
      extended by jncc20.NaiveBayes

 class NaiveBayes
extends NaiveClassifier

Implements the Naive Bayes Classifier (NBC), using Laplace prior (i.e., initializing all counts to 1).


Nested Class Summary
 
Nested classes/interfaces inherited from class jncc20.NaiveClassifier
NaiveClassifier.Feature, NaiveClassifier.OutputClass
 
Field Summary
private  double[][] estimatedProbabilities
          Probabilities estimated for each class, for each instance
private  int[] predictedInstances
          Index of the class predicted for each instance
 
Fields inherited from class jncc20.NaiveClassifier
featureSet, outputClasses, s
 
Constructor Summary
NaiveBayes(java.util.ArrayList<int[]> TrainingSet, java.util.ArrayList<java.lang.String> FeatureNames, java.util.ArrayList<java.lang.String> ClassNames, java.util.ArrayList<java.lang.Integer> NumClassForEachFeature)
          Initializes all features and output classes; trains the classifier on TrainingSet.
 
Method Summary
private  void classifyInstance(int[] SuppliedInstance, int InstanceIdx)
          Classify a single instance, writing the computed probabilities at position InstanceIdx of EstimatedProbabilities, and the predicted class at position InstanceIdx of PredictedInstances
(package private)  void classifyInstances(java.util.ArrayList<int[]> TestingSet)
          Classifies all the instances of the supplied TestingSet, writing the results of the computation into EstimatedProbabilities and PredictedInstances
(package private)  int[] getPredictedInstances()
           
 
Methods inherited from class jncc20.NaiveClassifier
buildFeatureSet, buildOutputClasses, getOutputClasses
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

estimatedProbabilities

private double[][] estimatedProbabilities
Probabilities estimated for each class, for each instance


predictedInstances

private int[] predictedInstances
Index of the class predicted for each instance

Constructor Detail

NaiveBayes

NaiveBayes(java.util.ArrayList<int[]> TrainingSet,
           java.util.ArrayList<java.lang.String> FeatureNames,
           java.util.ArrayList<java.lang.String> ClassNames,
           java.util.ArrayList<java.lang.Integer> NumClassForEachFeature)
Initializes all features and output classes; trains the classifier on TrainingSet.

Method Detail

classifyInstance

private void classifyInstance(int[] SuppliedInstance,
                              int InstanceIdx)
Classify a single instance, writing the computed probabilities at position InstanceIdx of EstimatedProbabilities, and the predicted class at position InstanceIdx of PredictedInstances


classifyInstances

void classifyInstances(java.util.ArrayList<int[]> TestingSet)
Classifies all the instances of the supplied TestingSet, writing the results of the computation into EstimatedProbabilities and PredictedInstances


getPredictedInstances

int[] getPredictedInstances()