jncc20
Class NaiveBayes
java.lang.Object
jncc20.NaiveClassifier
jncc20.NaiveBayes
class NaiveBayes
- extends NaiveClassifier
Implements the Naive Bayes Classifier (NBC) with Laplace prior
Field Summary |
private int[] |
predictions
Index of the class predicted for each instance |
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 probabilities, and the predicted class at position InstanceIdx of predictions |
(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[] |
getPredictions()
|
double[][] |
getProbabilities()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
predictions
private int[] predictions
- 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 probabilities, and the predicted class at position InstanceIdx of predictions
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
- Specified by:
classifyInstances
in class NaiveClassifier
getPredictions
int[] getPredictions()
getProbabilities
public double[][] getProbabilities()