def reportMeanAccyracyOfEpoch(self): trainOrValString = "TRAINING" if self.training0orValidation1 == 0 else "VALIDATION" logStr = trainOrValString + ": Epoch #" + str(self.epoch) # Report the multi-class accuracy first. self.log.print3( "( >>>>>>>>>>>>>>>>>>>> Reporting Accuracy over whole epoch <<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) meanEmpiricalAccOfEp = getMeanOfListExclNA( self.meanEmpiricalAccuracyOfEachSubep, self.NA_PATTERN) self.log.print3( logStr + ", Overall:\t mean accuracy of epoch:\t" + strFl4fNA(meanEmpiricalAccOfEp, self.NA_PATTERN) + "\t=> Correctly-Classified-Voxels/All-Predicted-Voxels") if self.training0orValidation1 == 0: # During training, also report the mean value of the Cost Function: meanCostOfEp = getMeanOfListExclNA(self.meanCostOfEachSubep, self.NA_PATTERN) self.log.print3(logStr + ", Overall:\t mean cost of epoch: \t" + strFl5fNA(meanCostOfEp, self.NA_PATTERN)) self.log.print3(logStr + ", Overall:\t mean accuracy of each subepoch:\t" + strListFl4fNA(self.meanEmpiricalAccuracyOfEachSubep, self.NA_PATTERN)) if self.training0orValidation1 == 0: self.log.print3( logStr + ", Overall:\t mean cost of each subepoch: \t" + strListFl5fNA(self.meanCostOfEachSubep, self.NA_PATTERN)) # Report for each class. for class_i in range(self.numberOfClasses): classString = "Class-" + str(class_i) extraDescription = "[Whole Foreground (Pos) Vs Background (Neg)]" if class_i == 0 else "[This Class (Pos) Vs All Others (Neg)]" self.log.print3( ">>>>>>>>>>>> Reporting Accuracy over whole epoch for " + classString + " >>>>>>>>> " + extraDescription + " <<<<<<<<<<<<<") if class_i != 0: meanAccPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i] [class_i][0] for subep_i in range( len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanSensPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i] [class_i][1] for subep_i in range( len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanPrecPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i] [class_i][2] for subep_i in range( len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanSpecPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i] [class_i][3] for subep_i in range( len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanDscPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i] [class_i][4] for subep_i in range( len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] else: # Foreground Vs Background meanAccPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][0] for subep_i in range( len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanSensPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][1] for subep_i in range( len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanPrecPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][2] for subep_i in range( len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanSpecPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][3] for subep_i in range( len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanDscPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][4] for subep_i in range( len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanAccOfEp = getMeanOfListExclNA(meanAccPerSubep, self.NA_PATTERN) meanSensOfEp = getMeanOfListExclNA(meanSensPerSubep, self.NA_PATTERN) meanPrecOfEp = getMeanOfListExclNA(meanPrecPerSubep, self.NA_PATTERN) meanSpecOfEp = getMeanOfListExclNA(meanSpecPerSubep, self.NA_PATTERN) meanDscOfEp = getMeanOfListExclNA(meanDscPerSubep, self.NA_PATTERN) logStrClass = logStr + ", " + classString + ":" self.log.print3(logStrClass + "\t mean accuracy of epoch:\t" + strFl4fNA(meanAccOfEp, self.NA_PATTERN) + "\t=> (TruePos+TrueNeg)/All-Predicted-Voxels") self.log.print3(logStrClass + "\t mean sensitivity of epoch:\t" + strFl4fNA(meanSensOfEp, self.NA_PATTERN) + "\t=> TruePos/RealPos") self.log.print3(logStrClass + "\t mean precision of epoch:\t" + strFl4fNA(meanPrecOfEp, self.NA_PATTERN) + "\t=> TruePos/(TruePos+FalsePos)") self.log.print3(logStrClass + "\t mean specificity of epoch:\t" + strFl4fNA(meanSpecOfEp, self.NA_PATTERN) + "\t=> TrueNeg/RealNeg") self.log.print3(logStrClass + "\t mean Dice of epoch: \t" + strFl4fNA(meanDscOfEp, self.NA_PATTERN)) #Visualised in my scripts: self.log.print3(logStrClass + "\t mean accuracy of each subepoch:\t" + strListFl4fNA(meanAccPerSubep, self.NA_PATTERN)) self.log.print3(logStrClass + "\t mean sensitivity of each subepoch:\t" + strListFl4fNA(meanSensPerSubep, self.NA_PATTERN)) self.log.print3(logStrClass + "\t mean precision of each subepoch:\t" + strListFl4fNA(meanPrecPerSubep, self.NA_PATTERN)) self.log.print3(logStrClass + "\t mean specificity of each subepoch:\t" + strListFl4fNA(meanSpecPerSubep, self.NA_PATTERN)) self.log.print3(logStrClass + "\t mean Dice of each subepoch: \t" + strListFl4fNA(meanDscPerSubep, self.NA_PATTERN)) self.log.print3( ">>>>>>>>>>>>>>>>>>>>>>>>> End Of Accuracy Report at the end of Epoch <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) self.log.print3( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" )
def reportMeanAccyracyOfEpoch(self) : trainOrValString = "TRAINING" if self.training0orValidation1 == 0 else "VALIDATION" logStr = trainOrValString + ": Epoch #" + str(self.epoch) # Report the multi-class accuracy first. self.log.print3( "( >>>>>>>>>>>>>>>>>>>> Reporting Accuracy over whole epoch <<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) meanEmpiricalAccOfEp = getMeanOfListExclNA(self.meanEmpiricalAccuracyOfEachSubep, self.NA_PATTERN) self.log.print3( logStr + ", Overall:\t mean accuracy of epoch:\t" + strFl4fNA(meanEmpiricalAccOfEp, self.NA_PATTERN)+"\t=> Correctly-Classified-Voxels/All-Predicted-Voxels") if self.training0orValidation1 == 0 : # During training, also report the mean value of the Cost Function: meanCostOfEp = getMeanOfListExclNA(self.meanCostOfEachSubep, self.NA_PATTERN) self.log.print3( logStr + ", Overall:\t mean cost of epoch: \t" + strFl5fNA(meanCostOfEp, self.NA_PATTERN) ) self.log.print3( logStr + ", Overall:\t mean accuracy of each subepoch:\t"+ strListFl4fNA(self.meanEmpiricalAccuracyOfEachSubep, self.NA_PATTERN) ) if self.training0orValidation1 == 0 : self.log.print3( logStr + ", Overall:\t mean cost of each subepoch: \t" + strListFl5fNA(self.meanCostOfEachSubep, self.NA_PATTERN) ) # Report for each class. for class_i in range(self.numberOfClasses) : classString = "Class-"+str(class_i) extraDescription = "[Whole Foreground (Pos) Vs Background (Neg)]" if class_i == 0 else "[This Class (Pos) Vs All Others (Neg)]" self.log.print3( ">>>>>>>>>>>> Reporting Accuracy over whole epoch for " + classString + " >>>>>>>>> " + extraDescription + " <<<<<<<<<<<<<" ) if class_i != 0 : meanAccPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][0] for subep_i in range(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanSensPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][1] for subep_i in range(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanPrecPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][2] for subep_i in range(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanSpecPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][3] for subep_i in range(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanDscPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][4] for subep_i in range(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] else : # Foreground Vs Background meanAccPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][0] for subep_i in range(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanSensPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][1] for subep_i in range(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanPrecPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][2] for subep_i in range(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanSpecPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][3] for subep_i in range(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanDscPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][4] for subep_i in range(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanAccOfEp = getMeanOfListExclNA(meanAccPerSubep, self.NA_PATTERN) meanSensOfEp = getMeanOfListExclNA(meanSensPerSubep, self.NA_PATTERN) meanPrecOfEp = getMeanOfListExclNA(meanPrecPerSubep, self.NA_PATTERN) meanSpecOfEp = getMeanOfListExclNA(meanSpecPerSubep, self.NA_PATTERN) meanDscOfEp = getMeanOfListExclNA(meanDscPerSubep, self.NA_PATTERN) logStrClass = logStr + ", " + classString + ":" self.log.print3(logStrClass + "\t mean accuracy of epoch:\t"+ strFl4fNA(meanAccOfEp, self.NA_PATTERN) +"\t=> (TruePos+TrueNeg)/All-Predicted-Voxels") self.log.print3(logStrClass + "\t mean sensitivity of epoch:\t"+ strFl4fNA(meanSensOfEp, self.NA_PATTERN) +"\t=> TruePos/RealPos") self.log.print3(logStrClass + "\t mean precision of epoch:\t"+ strFl4fNA(meanPrecOfEp, self.NA_PATTERN) +"\t=> TruePos/(TruePos+FalsePos)") self.log.print3(logStrClass + "\t mean specificity of epoch:\t"+ strFl4fNA(meanSpecOfEp, self.NA_PATTERN) +"\t=> TrueNeg/RealNeg") self.log.print3(logStrClass + "\t mean Dice of epoch: \t"+ strFl4fNA(meanDscOfEp, self.NA_PATTERN) ) #Visualised in my scripts: self.log.print3(logStrClass + "\t mean accuracy of each subepoch:\t"+ strListFl4fNA(meanAccPerSubep, self.NA_PATTERN) ) self.log.print3(logStrClass + "\t mean sensitivity of each subepoch:\t" + strListFl4fNA(meanSensPerSubep, self.NA_PATTERN) ) self.log.print3(logStrClass + "\t mean precision of each subepoch:\t" + strListFl4fNA(meanPrecPerSubep, self.NA_PATTERN) ) self.log.print3(logStrClass + "\t mean specificity of each subepoch:\t" + strListFl4fNA(meanSpecPerSubep, self.NA_PATTERN) ) self.log.print3(logStrClass + "\t mean Dice of each subepoch: \t" + strListFl4fNA(meanDscPerSubep, self.NA_PATTERN) ) self.log.print3( ">>>>>>>>>>>>>>>>>>>>>>>>> End Of Accuracy Report at the end of Epoch <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) self.log.print3( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" )