jncc20
Class NaiveBayes
java.lang.Object
jncc20.NaiveClassifier
jncc20.NaiveBayes
class NaiveBayes
- extends NaiveClassifier
Implements the Naive Bayes Classifier (NBC), using Laplace prior (i.e.,
initializing all counts to 1).
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
estimatedProbabilities
private double[][] estimatedProbabilities
- Probabilities estimated for each class, for each instance
predictedInstances
private int[] predictedInstances
- Index of the class predicted for each instance
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.
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()