jncc20
Class Jncc.ResultsReporter

java.lang.Object
  extended by jncc20.Jncc.ResultsReporter
Enclosing class:
Jncc

private class Jncc.ResultsReporter
extends java.lang.Object

Helper class for jncc, which accomplishes the following tasks: reads the temporary file where NBC and NCC predictions are stored; computes performances indexes; produces the output files, i.e., ResultsTable.csv (performance indicators), ConfMatrices.txt (confusion matrices) and, if a testing file is supplied, Prediction-.csv (instances and predictions of the testing file).


Field Summary
private  int actualClass
           
private  double[] aNbcAcc
           
private  double[] aNccI
           
private  double[] aNccOutputSize
           
private  double[] aNccP
           
private  double[] aNccPrec
           
private  double[] aNccSetAcc
           
private  double[] aNccSingleAcc
           
private  java.lang.String indicatorsFile
          Temporary file, where the performance indicators are saved fold-by-fold
private  int instancesCounter
           
private  java.lang.Boolean nbcAccCurrentInst
           
private  int nbcAccNccImprecise
           
private  int nbcAccNccprecise
           
private  int nbcAccurate
           
private  int[][] nbcConfMatrix
           
private  int[][] nccConfMatrix
           
private  int nccImprecise
           
private  int nccImpreciseOutputSize
           
private  int nccPrecise
           
private  int nccPreciseAccurate
           
private  int nccSetAccurate
           
private  int numClasses
           
private  int numRuns
          how many training/testing experiments (1 for testing, num runs*num folds for CV) the predictions saved to file reg
 
Constructor Summary
Jncc.ResultsReporter()
          Constructor
 
Method Summary
private  void analyzePredictionsFile()
          Computes statistics accuracy of NBC NCC and Bma by analyzing the predictions saved on a temporary file; then, saves to file the computed indicators (fold by fold); parse the indicator file and allocates all the indicators into arrays.
private  void parseIndicatorFile()
           
private  void parseNbcNccPrediction(java.util.StringTokenizer st)
          Reads and evaluates a single Ncc prediction retrieved from the prediction file, and updates the indexes referring to NBC accuracy when NCC precise/imprecise
private  void parseNbcPrediction(java.lang.String currentToken)
          Reads and assesses a single Nbc prediction retrieved from the prediction file; its accuracy or not on the supplied instance is tracked by the member variable nbcAccCurrentInst
private  void resetCounters()
          Set all counters to 0
private  void saveTmpStats(java.io.BufferedWriter out)
          Saves to a temporary file the performance indicators (a row for each single training/testing experiment), to be later averaged
private  void writeConfMatrix(java.lang.String classifier)
          Writes confusion matrix to file, preceeding it by a title which depends on the classifier parameter (nbc or ncc2); the confusion matrix is appended into a an already existing file (if the file is not existing, it is created)
private  void writeOutputFiles()
          Parses the temporary file where performance indicators (measured fold by fold) have been stored , and produces the output files, i.e, resultsTable and confusionMatrix.
private  void writeStdDev(double[] array, java.io.BufferedWriter out, java.text.DecimalFormat formatter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actualClass

private int actualClass

aNbcAcc

private double[] aNbcAcc

aNccI

private double[] aNccI

aNccOutputSize

private double[] aNccOutputSize

aNccP

private double[] aNccP

aNccPrec

private double[] aNccPrec

aNccSetAcc

private double[] aNccSetAcc

aNccSingleAcc

private double[] aNccSingleAcc

indicatorsFile

private java.lang.String indicatorsFile
Temporary file, where the performance indicators are saved fold-by-fold


instancesCounter

private int instancesCounter

nbcAccCurrentInst

private java.lang.Boolean nbcAccCurrentInst

nbcAccNccImprecise

private int nbcAccNccImprecise

nbcAccNccprecise

private int nbcAccNccprecise

nbcAccurate

private int nbcAccurate

nbcConfMatrix

private int[][] nbcConfMatrix

nccConfMatrix

private int[][] nccConfMatrix

nccImprecise

private int nccImprecise

nccImpreciseOutputSize

private int nccImpreciseOutputSize

nccPrecise

private int nccPrecise

nccPreciseAccurate

private int nccPreciseAccurate

nccSetAccurate

private int nccSetAccurate

numClasses

private int numClasses

numRuns

private int numRuns
how many training/testing experiments (1 for testing, num runs*num folds for CV) the predictions saved to file reg

Constructor Detail

Jncc.ResultsReporter

Jncc.ResultsReporter()
Constructor

Method Detail

analyzePredictionsFile

private void analyzePredictionsFile()
Computes statistics accuracy of NBC NCC and Bma by analyzing the predictions saved on a temporary file; then, saves to file the computed indicators (fold by fold); parse the indicator file and allocates all the indicators into arrays. Then, both prediction file and indicator file are deleted. The file is expected to be made up by many rows arranged as follows:

FoldNumber | Actual Class | NBC prediction | NCC prediction (nc cols) | Bma prediction(1 col) | Bma num of significant models (1 col)

where nc is the number of classes.


parseIndicatorFile

private void parseIndicatorFile()

parseNbcNccPrediction

private void parseNbcNccPrediction(java.util.StringTokenizer st)
Reads and evaluates a single Ncc prediction retrieved from the prediction file, and updates the indexes referring to NBC accuracy when NCC precise/imprecise


parseNbcPrediction

private void parseNbcPrediction(java.lang.String currentToken)
Reads and assesses a single Nbc prediction retrieved from the prediction file; its accuracy or not on the supplied instance is tracked by the member variable nbcAccCurrentInst


resetCounters

private void resetCounters()
Set all counters to 0


saveTmpStats

private void saveTmpStats(java.io.BufferedWriter out)
Saves to a temporary file the performance indicators (a row for each single training/testing experiment), to be later averaged


writeConfMatrix

private void writeConfMatrix(java.lang.String classifier)
Writes confusion matrix to file, preceeding it by a title which depends on the classifier parameter (nbc or ncc2); the confusion matrix is appended into a an already existing file (if the file is not existing, it is created)


writeOutputFiles

private void writeOutputFiles()
Parses the temporary file where performance indicators (measured fold by fold) have been stored , and produces the output files, i.e, resultsTable and confusionMatrix. The resultsTable creates , a row of indicators for each data set; confusion matrices are instead appended into a single file.


writeStdDev

private void writeStdDev(double[] array,
                         java.io.BufferedWriter out,
                         java.text.DecimalFormat formatter)