jncc20
Class NaiveClassifier

java.lang.Object
  extended by jncc20.NaiveClassifier
Direct Known Subclasses:
NaiveBayes, NaiveCredalClassifier

public abstract class NaiveClassifier
extends java.lang.Object

Abstract super-class for Naive Classifiers


Nested Class Summary
protected static class NaiveClassifier.Feature
          Helper class for Naive Classifiers, that implements Mar and NonMar features.
protected  class NaiveClassifier.OutputClass
          Helper class for Naive Classifiers, that implements the output class of the classification problem.
 
Field Summary
protected  NaiveClassifier.Feature[] featureSet
          Array of Feature objects, that represents the feature set of the classifier
protected  NaiveClassifier.OutputClass[] outputClasses
          Array of OutputClass objects, that represents the possible output classes of the problem
protected  int s
          number of "hidden" observations, that rules the weights of the prior with respect to the likelihood.
 
Constructor Summary
NaiveClassifier()
          Empty constructor, needed to compile
NaiveClassifier(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; computes all the relevant frequencies on the training set
 
Method Summary
protected  void buildFeatureSet(java.util.ArrayList<int[]> TrainingSet, java.util.ArrayList<java.lang.String> FeatureNames, int NumOfClasses, java.util.ArrayList<java.lang.Integer> NumClassForEachFeature, int priorCounts)
          Instantiates the FeatureSet, by computing all the relevant frequencies of all features on the training set.
protected  void buildOutputClasses(java.util.ArrayList<int[]> TrainingSet, java.util.ArrayList<java.lang.String> ClassNames, int priorCounts)
          Instantiates class names and frequencies of the OutputClass; frequencies are initialized to the value specified by priorCounts (1 for NBC, 0 for NCC)
(package private)  NaiveClassifier.OutputClass[] getOutputClasses()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

featureSet

protected NaiveClassifier.Feature[] featureSet
Array of Feature objects, that represents the feature set of the classifier


outputClasses

protected NaiveClassifier.OutputClass[] outputClasses
Array of OutputClass objects, that represents the possible output classes of the problem


s

protected int s
number of "hidden" observations, that rules the weights of the prior with respect to the likelihood. It is a safe choice to set it as 1 or 2.

Constructor Detail

NaiveClassifier

NaiveClassifier()
Empty constructor, needed to compile


NaiveClassifier

NaiveClassifier(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; computes all the relevant frequencies on the training set

Method Detail

buildFeatureSet

protected void buildFeatureSet(java.util.ArrayList<int[]> TrainingSet,
                               java.util.ArrayList<java.lang.String> FeatureNames,
                               int NumOfClasses,
                               java.util.ArrayList<java.lang.Integer> NumClassForEachFeature,
                               int priorCounts)
Instantiates the FeatureSet, by computing all the relevant frequencies of all features on the training set. In particular, it computes:

the bivariates count n(a_i,c_j), that correspond to the occurences ignoring missing data for NBC, and to the lower counts for NCC;

for each output class, the number of missing data of the current feature, needed to then compute the upper counts for NCC


buildOutputClasses

protected void buildOutputClasses(java.util.ArrayList<int[]> TrainingSet,
                                  java.util.ArrayList<java.lang.String> ClassNames,
                                  int priorCounts)
Instantiates class names and frequencies of the OutputClass; frequencies are initialized to the value specified by priorCounts (1 for NBC, 0 for NCC)


getOutputClasses

NaiveClassifier.OutputClass[] getOutputClasses()