jncc20
Class NaiveCredalClassifier

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

 class NaiveCredalClassifier
extends NaiveClassifier

Implementation of the Naive Credal Classifier (NCC).


Nested Class Summary
private static class NaiveCredalClassifier.PartitionPoint
          Helper class for NaiveCredal Classifier, used to store crossing points and minimizing tuples; it is used when missing data in the NonMar part of the testing instances.
 
Nested classes/interfaces inherited from class jncc20.NaiveClassifier
NaiveClassifier.Feature, NaiveClassifier.OutputClass
 
Field Summary
private  int[][] credalPredictedInstances
          Stores NCC predictions; as every prediction can be imprecise and hence contain several value, it is implemented as a matrix.
private  int k
          Number of NonMar features in training
private  java.util.ArrayList<java.lang.Integer> nonMarTestingIdx
          Indexes of nonMarFeature in testing
private  java.util.ArrayList<java.lang.Integer> nonMarTrainingIdx
          Indexes of nonMarFeature in training
private  java.util.ArrayList<java.lang.Integer> numClassesNonMarTesting
          Number of classes of each NonMar variable in Testing
private  java.util.ArrayList<NaiveCredalClassifier.PartitionPoint> partitionPoints
          Partition Points, used when classyfing instances with missing units in the NonMar part.
 
Fields inherited from class jncc20.NaiveClassifier
featureSet, outputClasses, s
 
Constructor Summary
NaiveCredalClassifier(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, java.util.ArrayList<java.lang.Integer> SuppliedNonMarInTraining, java.util.ArrayList<java.lang.Integer> SuppliedNonMarInTesting, java.util.ArrayList<java.lang.Integer> SuppliedNumClassesNonMarTesting)
          Builds feature and output class, and computes the relevant counts for MAR and NON-MAR features
 
Method Summary
private  double checkCredalDominanceCIR(int c1, int c2, int[] currentInstance, double xmin, double xmax)
          Computes the CIR test of dominance between class c1 and c2 (if the returned value is >1, c1 dominates c2)
private  int[] classifyInstance(int[] CurrentInstance)
          Classifies a single instance, returning the list of predicted classes
(package private)  void classifyInstances(java.util.ArrayList<int[]> TestingSet)
          Classify all the instances of the supplied TestingSet; stores the predictions into CredalPredictedInstances
private  double computeDeriv2LnHxCIR(int alpha, int beta, java.util.ArrayList<java.lang.Integer> betaArr, java.util.ArrayList<java.lang.Integer> gammaArr, java.util.ArrayList<java.lang.Integer> deltaArr, java.util.ArrayList<java.lang.Integer> gammaTildeArr, java.util.ArrayList<java.lang.Integer> deltaTildeArr, double x)
          Computes the second derivative of Ln(Hx) (see Corani and Zaffalon, 2007)
private  double computeDerivLnHxCIR(int alpha, int beta, java.util.ArrayList<java.lang.Integer> alphaArr, java.util.ArrayList<java.lang.Integer> betaArr, java.util.ArrayList<java.lang.Integer> gammaArr, java.util.ArrayList<java.lang.Integer> deltaArr, java.util.ArrayList<java.lang.Integer> gammaTildeArr, java.util.ArrayList<java.lang.Integer> deltaTildeArr, double x)
          Computes the derivative of Ln(Hx) (see Corani and Zaffalon, 2007)
private  double computeHxCIR(int alpha, int beta, java.util.ArrayList<java.lang.Integer> alphaArr, java.util.ArrayList<java.lang.Integer> betaArr, java.util.ArrayList<java.lang.Integer> gammaArr, java.util.ArrayList<java.lang.Integer> deltaArr, java.util.ArrayList<java.lang.Integer> gammaTildeArr, java.util.ArrayList<java.lang.Integer> deltaTildeArr, double x)
          Computes Hx for a given value of x, alpha, beta ecc.
private  int findMinimizingValue(int FeatureIdx, int NumValues, int c1, int c2, double xmin, double xmax)
          Given a sub-partion (xmin,xmax) of[0,s], returns the value of feature FeatureIdx, which minimizes the ratio (lowercount(feature,c1)/(uppercount(feature,c2)+x)) in the interval.
private  boolean findPartitionPoints(int c1, int c2, java.util.ArrayList<java.lang.Integer> MissingNonMarIdx)
          If there are missing data in the NonMar part of the units to be classified, this function identifies the intervals in which the range [0,s] has to be sub-partitioned.
private  double findZeroCIR(double x1, double x2, int alpha, int beta, java.util.ArrayList<java.lang.Integer> alphaArr, java.util.ArrayList<java.lang.Integer> betaArr, java.util.ArrayList<java.lang.Integer> gammaArr, java.util.ArrayList<java.lang.Integer> deltaArr, java.util.ArrayList<java.lang.Integer> gammaTildeArr, java.util.ArrayList<java.lang.Integer> deltaTildeArr)
          Numerical approximation of the min of Ln(Hx) via Newton-Raphson method.
(package private)  int[][] getCredalPredictedInstances()
          Returns the matrix of the predictions
(package private)  int[] getCredalPredictedInstances(int idx)
          Returns the vector, which contains the prediction for instance in position idx
(package private)  void instancesAndPredictionsToFileUnknownClasses(java.lang.String suppliedWorkingPath, java.lang.String suppliedArffTestingFile, java.util.ArrayList<java.lang.String[]> RawTestingSet)
          Write to file the instances and the classifications returned by the NCC; when the actual classes are unknown, this constitutes the only output of the classifier.
 
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

credalPredictedInstances

private int[][] credalPredictedInstances
Stores NCC predictions; as every prediction can be imprecise and hence contain several value, it is implemented as a matrix.


k

private int k
Number of NonMar features in training


nonMarTestingIdx

private java.util.ArrayList<java.lang.Integer> nonMarTestingIdx
Indexes of nonMarFeature in testing


nonMarTrainingIdx

private java.util.ArrayList<java.lang.Integer> nonMarTrainingIdx
Indexes of nonMarFeature in training


numClassesNonMarTesting

private java.util.ArrayList<java.lang.Integer> numClassesNonMarTesting
Number of classes of each NonMar variable in Testing


partitionPoints

private java.util.ArrayList<NaiveCredalClassifier.PartitionPoint> partitionPoints
Partition Points, used when classyfing instances with missing units in the NonMar part.

Constructor Detail

NaiveCredalClassifier

NaiveCredalClassifier(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,
                      java.util.ArrayList<java.lang.Integer> SuppliedNonMarInTraining,
                      java.util.ArrayList<java.lang.Integer> SuppliedNonMarInTesting,
                      java.util.ArrayList<java.lang.Integer> SuppliedNumClassesNonMarTesting)
Builds feature and output class, and computes the relevant counts for MAR and NON-MAR features

Method Detail

checkCredalDominanceCIR

private double checkCredalDominanceCIR(int c1,
                                       int c2,
                                       int[] currentInstance,
                                       double xmin,
                                       double xmax)
Computes the CIR test of dominance between class c1 and c2 (if the returned value is >1, c1 dominates c2)


classifyInstance

private int[] classifyInstance(int[] CurrentInstance)
Classifies a single instance, returning the list of predicted classes


classifyInstances

void classifyInstances(java.util.ArrayList<int[]> TestingSet)
Classify all the instances of the supplied TestingSet; stores the predictions into CredalPredictedInstances


computeDeriv2LnHxCIR

private double computeDeriv2LnHxCIR(int alpha,
                                    int beta,
                                    java.util.ArrayList<java.lang.Integer> betaArr,
                                    java.util.ArrayList<java.lang.Integer> gammaArr,
                                    java.util.ArrayList<java.lang.Integer> deltaArr,
                                    java.util.ArrayList<java.lang.Integer> gammaTildeArr,
                                    java.util.ArrayList<java.lang.Integer> deltaTildeArr,
                                    double x)
Computes the second derivative of Ln(Hx) (see Corani and Zaffalon, 2007)


computeDerivLnHxCIR

private double computeDerivLnHxCIR(int alpha,
                                   int beta,
                                   java.util.ArrayList<java.lang.Integer> alphaArr,
                                   java.util.ArrayList<java.lang.Integer> betaArr,
                                   java.util.ArrayList<java.lang.Integer> gammaArr,
                                   java.util.ArrayList<java.lang.Integer> deltaArr,
                                   java.util.ArrayList<java.lang.Integer> gammaTildeArr,
                                   java.util.ArrayList<java.lang.Integer> deltaTildeArr,
                                   double x)
Computes the derivative of Ln(Hx) (see Corani and Zaffalon, 2007)


computeHxCIR

private double computeHxCIR(int alpha,
                            int beta,
                            java.util.ArrayList<java.lang.Integer> alphaArr,
                            java.util.ArrayList<java.lang.Integer> betaArr,
                            java.util.ArrayList<java.lang.Integer> gammaArr,
                            java.util.ArrayList<java.lang.Integer> deltaArr,
                            java.util.ArrayList<java.lang.Integer> gammaTildeArr,
                            java.util.ArrayList<java.lang.Integer> deltaTildeArr,
                            double x)
Computes Hx for a given value of x, alpha, beta ecc. (see Corani and Zaffalon, 2007)


findMinimizingValue

private int findMinimizingValue(int FeatureIdx,
                                int NumValues,
                                int c1,
                                int c2,
                                double xmin,
                                double xmax)
Given a sub-partion (xmin,xmax) of[0,s], returns the value of feature FeatureIdx, which minimizes the ratio (lowercount(feature,c1)/(uppercount(feature,c2)+x)) in the interval.


findPartitionPoints

private boolean findPartitionPoints(int c1,
                                    int c2,
                                    java.util.ArrayList<java.lang.Integer> MissingNonMarIdx)
If there are missing data in the NonMar part of the units to be classified, this function identifies the intervals in which the range [0,s] has to be sub-partitioned. Later, the test of dominance has to performed separately on each sub-partition.


findZeroCIR

private double findZeroCIR(double x1,
                           double x2,
                           int alpha,
                           int beta,
                           java.util.ArrayList<java.lang.Integer> alphaArr,
                           java.util.ArrayList<java.lang.Integer> betaArr,
                           java.util.ArrayList<java.lang.Integer> gammaArr,
                           java.util.ArrayList<java.lang.Integer> deltaArr,
                           java.util.ArrayList<java.lang.Integer> gammaTildeArr,
                           java.util.ArrayList<java.lang.Integer> deltaTildeArr)
Numerical approximation of the min of Ln(Hx) via Newton-Raphson method.


getCredalPredictedInstances

int[][] getCredalPredictedInstances()
Returns the matrix of the predictions


getCredalPredictedInstances

int[] getCredalPredictedInstances(int idx)
Returns the vector, which contains the prediction for instance in position idx


instancesAndPredictionsToFileUnknownClasses

void instancesAndPredictionsToFileUnknownClasses(java.lang.String suppliedWorkingPath,
                                                 java.lang.String suppliedArffTestingFile,
                                                 java.util.ArrayList<java.lang.String[]> RawTestingSet)
Write to file the instances and the classifications returned by the NCC; when the actual classes are unknown, this constitutes the only output of the classifier. Note that, because of the discretization, different number of features might appear in different runs of CV