def reportAccuracyForLastSubepoch(self) : trainOrValString = "TRAINING" if self.training0orValidation1 == 0 else "VALIDATION" numberOfClasses = self.numberOfClasses currSubep = self.numberOfSubepochsForWhichUpdated - 1 logStr = trainOrValString + ": Epoch #" + str(self.epoch) + ", Subepoch #" + str(currSubep) self.logger.print3( "+++++++++++++++++++++++ Reporting Accuracy over whole subepoch +++++++++++++++++++++++" ) self.logger.print3( logStr + ", Overall:\t mean accuracy: \t" + strFl4fNA(self.meanEmpiricalAccuracyOfEachSubep[currSubep], self.NA_PATTERN) +\ "\t=> Correctly-Classified-Voxels/All-Predicted-Voxels = " + str(self.correctlyPredVoxelsInEachSubep[currSubep]) + "/" + str(self.numberOfAllSamplesOfEachSubep[currSubep]) ) if self.training0orValidation1 == 0 : # During training, also report the mean value of the Cost Function: self.logger.print3( logStr + ", Overall:\t mean cost: \t" + strFl5fNA(self.meanCostOfEachSubep[currSubep], self.NA_PATTERN) ) # Report accuracy over subepoch for each class_i: for class_i in xrange(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.logger.print3( "+++++++++++++++ Reporting Accuracy over whole subepoch for " + classString + " ++++++++ " + extraDescription + " ++++++++++++++++" ) [meanAccClassOfSubep, meanAccOnPosOfSubep, meanAccOnNegOfSubep, meanDiceOfSubep ] = self.listPerSubepPerClassMeanAccSensSpecDsc[currSubep][class_i] if class_i <> 0 else \ self.listPerSubepForegrMeanAccSensSpecDsc[currSubep] # If class-0, report foreground. [numOfRpInSubep, numOfRnInSubep, numOfTpInSubep, numOfTnInSubep] = self.listPerSubepPerClassRpRnTpTn[currSubep][class_i] if class_i <> 0 else \ self.listPerSubepForegrRpRnTpTn[currSubep] # If class-0, report foreground. logStrClass = logStr + ", " + classString + ":" self.logger.print3(logStrClass+"\t mean accuracy: \t"+ strFl4fNA(meanAccClassOfSubep, self.NA_PATTERN)+"\t=> (TruePos+TrueNeg)/All-Predicted-Voxels = "+str(numOfTpInSubep+numOfTnInSubep)+"/"+str(numOfRpInSubep+numOfRnInSubep)) self.logger.print3(logStrClass+"\t mean sensitivity:\t"+ strFl4fNA(meanAccOnPosOfSubep, self.NA_PATTERN)+"\t=> TruePos/RealPos = "+str(numOfTpInSubep)+"/"+str(numOfRpInSubep)) self.logger.print3(logStrClass+"\t mean specificity:\t"+ strFl4fNA(meanAccOnNegOfSubep, self.NA_PATTERN)+"\t=> TrueNeg/RealNeg = "+str(numOfTnInSubep)+"/"+str(numOfRnInSubep)) self.logger.print3(logStrClass+"\t mean Dice: \t"+ strFl4fNA(meanDiceOfSubep, self.NA_PATTERN))
def reportAccuracyForLastSubepoch(self) : trainOrValString = "TRAINING" if self.training0orValidation1 == 0 else "VALIDATION" numberOfClasses = self.numberOfClasses currSubep = self.numberOfSubepochsForWhichUpdated - 1 logStr = trainOrValString + ": Epoch #" + str(self.epoch) + ", Subepoch #" + str(currSubep) self.logger.print3( "+++++++++++++++++++++++ Reporting Accuracy over whole subepoch +++++++++++++++++++++++" ) self.logger.print3( logStr + ", Overall:\t mean accuracy: \t" + strFl4fNA(self.meanEmpiricalAccuracyOfEachSubep[currSubep], self.NA_PATTERN) +\ "\t=> Correctly-Classified-Voxels/All-Predicted-Voxels = " + str(self.correctlyPredVoxelsInEachSubep[currSubep]) + "/" + str(self.numberOfAllSamplesOfEachSubep[currSubep]) ) if self.training0orValidation1 == 0 : # During training, also report the mean value of the Cost Function: self.logger.print3( logStr + ", Overall:\t mean cost: \t" + strFl5fNA(self.meanCostOfEachSubep[currSubep], self.NA_PATTERN) ) # Report accuracy over subepoch for each class_i: for class_i in xrange(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.logger.print3( "+++++++++++++++ Reporting Accuracy over whole subepoch for " + classString + " ++++++++ " + extraDescription + " ++++++++++++++++" ) [meanAccClassOfSubep, meanAccOnPosOfSubep, meanAccOnNegOfSubep, meanDiceOfSubep ] = self.listPerSubepPerClassMeanAccSensSpecDsc[currSubep][class_i] if class_i != 0 else \ self.listPerSubepForegrMeanAccSensSpecDsc[currSubep] # If class-0, report foreground. [numOfRpInSubep, numOfRnInSubep, numOfTpInSubep, numOfTnInSubep] = self.listPerSubepPerClassRpRnTpTn[currSubep][class_i] if class_i != 0 else \ self.listPerSubepForegrRpRnTpTn[currSubep] # If class-0, report foreground. logStrClass = logStr + ", " + classString + ":" self.logger.print3(logStrClass+"\t mean accuracy: \t"+ strFl4fNA(meanAccClassOfSubep, self.NA_PATTERN)+"\t=> (TruePos+TrueNeg)/All-Predicted-Voxels = "+str(numOfTpInSubep+numOfTnInSubep)+"/"+str(numOfRpInSubep+numOfRnInSubep)) self.logger.print3(logStrClass+"\t mean sensitivity:\t"+ strFl4fNA(meanAccOnPosOfSubep, self.NA_PATTERN)+"\t=> TruePos/RealPos = "+str(numOfTpInSubep)+"/"+str(numOfRpInSubep)) self.logger.print3(logStrClass+"\t mean specificity:\t"+ strFl4fNA(meanAccOnNegOfSubep, self.NA_PATTERN)+"\t=> TrueNeg/RealNeg = "+str(numOfTnInSubep)+"/"+str(numOfRnInSubep)) self.logger.print3(logStrClass+"\t mean Dice: \t"+ strFl4fNA(meanDiceOfSubep, self.NA_PATTERN))
def reportMeanAccyracyOfEpoch(self) : trainOrValString = "TRAINING" if self.training0orValidation1 == 0 else "VALIDATION" logStr = trainOrValString + ": Epoch #" + str(self.epoch) # Report the multi-class accuracy first. self.logger.print3( "( >>>>>>>>>>>>>>>>>>>> Reporting Accuracy over whole epoch <<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) meanEmpiricalAccOfEp = getMeanOfListExclNA(self.meanEmpiricalAccuracyOfEachSubep, self.NA_PATTERN) self.logger.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.logger.print3( logStr + ", Overall:\t mean cost of epoch: \t" + strFl5fNA(meanCostOfEp, self.NA_PATTERN) ) self.logger.print3( logStr + ", Overall:\t mean accuracy of each subepoch:\t"+ strListFl4fNA(self.meanEmpiricalAccuracyOfEachSubep, self.NA_PATTERN) ) if self.training0orValidation1 == 0 : self.logger.print3( logStr + ", Overall:\t mean cost of each subepoch: \t" + strListFl5fNA(self.meanCostOfEachSubep, self.NA_PATTERN) ) # Report for each class. for class_i in xrange(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.logger.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 xrange(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanSensPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][1] for subep_i in xrange(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanSpecPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][2] for subep_i in xrange(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanDscPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][3] for subep_i in xrange(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] else : # Foreground Vs Background meanAccPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][0] for subep_i in xrange(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanSensPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][1] for subep_i in xrange(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanSpecPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][2] for subep_i in xrange(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanDscPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][3] for subep_i in xrange(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanAccOfEp = getMeanOfListExclNA(meanAccPerSubep, self.NA_PATTERN) meanSensOfEp = getMeanOfListExclNA(meanSensPerSubep, self.NA_PATTERN) meanSpecOfEp = getMeanOfListExclNA(meanSpecPerSubep, self.NA_PATTERN) meanDscOfEp = getMeanOfListExclNA(meanDscPerSubep, self.NA_PATTERN) logStrClass = logStr + ", " + classString + ":" self.logger.print3(logStrClass + "\t mean accuracy of epoch:\t"+ strFl4fNA(meanAccOfEp, self.NA_PATTERN) +"\t=> (TruePos+TrueNeg)/All-Predicted-Voxels") self.logger.print3(logStrClass + "\t mean sensitivity of epoch:\t"+ strFl4fNA(meanSensOfEp, self.NA_PATTERN) +"\t=> TruePos/RealPos") self.logger.print3(logStrClass + "\t mean specificity of epoch:\t"+ strFl4fNA(meanSpecOfEp, self.NA_PATTERN) +"\t=> TrueNeg/RealNeg") self.logger.print3(logStrClass + "\t mean Dice of epoch: \t"+ strFl4fNA(meanDscOfEp, self.NA_PATTERN) ) #Visualised in my scripts: self.logger.print3(logStrClass + "\t mean accuracy of each subepoch:\t"+ strListFl4fNA(meanAccPerSubep, self.NA_PATTERN) ) self.logger.print3(logStrClass + "\t mean sensitivity of each subepoch:\t" + strListFl4fNA(meanSensPerSubep, self.NA_PATTERN) ) self.logger.print3(logStrClass + "\t mean specificity of each subepoch:\t" + strListFl4fNA(meanSpecPerSubep, self.NA_PATTERN) ) self.logger.print3(logStrClass + "\t mean Dice of each subepoch: \t" + strListFl4fNA(meanDscPerSubep, self.NA_PATTERN) ) self.logger.print3( ">>>>>>>>>>>>>>>>>>>>>>>>> End Of Accuracy Report at the end of Epoch <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) self.logger.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.logger.print3( "( >>>>>>>>>>>>>>>>>>>> Reporting Accuracy over whole epoch <<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) meanEmpiricalAccOfEp = getMeanOfListExclNA(self.meanEmpiricalAccuracyOfEachSubep, self.NA_PATTERN) self.logger.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.logger.print3( logStr + ", Overall:\t mean cost of epoch: \t" + strFl5fNA(meanCostOfEp, self.NA_PATTERN) ) self.logger.print3( logStr + ", Overall:\t mean accuracy of each subepoch:\t"+ strListFl4fNA(self.meanEmpiricalAccuracyOfEachSubep, self.NA_PATTERN) ) if self.training0orValidation1 == 0 : self.logger.print3( logStr + ", Overall:\t mean cost of each subepoch: \t" + strListFl5fNA(self.meanCostOfEachSubep, self.NA_PATTERN) ) # Report for each class. for class_i in xrange(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.logger.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 xrange(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanSensPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][1] for subep_i in xrange(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanSpecPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][2] for subep_i in xrange(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] meanDscPerSubep = [ self.listPerSubepPerClassMeanAccSensSpecDsc[subep_i][class_i][3] for subep_i in xrange(len(self.listPerSubepPerClassMeanAccSensSpecDsc)) ] else : # Foreground Vs Background meanAccPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][0] for subep_i in xrange(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanSensPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][1] for subep_i in xrange(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanSpecPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][2] for subep_i in xrange(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanDscPerSubep = [ self.listPerSubepForegrMeanAccSensSpecDsc[subep_i][3] for subep_i in xrange(len(self.listPerSubepForegrMeanAccSensSpecDsc)) ] meanAccOfEp = getMeanOfListExclNA(meanAccPerSubep, self.NA_PATTERN) meanSensOfEp = getMeanOfListExclNA(meanSensPerSubep, self.NA_PATTERN) meanSpecOfEp = getMeanOfListExclNA(meanSpecPerSubep, self.NA_PATTERN) meanDscOfEp = getMeanOfListExclNA(meanDscPerSubep, self.NA_PATTERN) logStrClass = logStr + ", " + classString + ":" self.logger.print3(logStrClass + "\t mean accuracy of epoch:\t"+ strFl4fNA(meanAccOfEp, self.NA_PATTERN) +"\t=> (TruePos+TrueNeg)/All-Predicted-Voxels") self.logger.print3(logStrClass + "\t mean sensitivity of epoch:\t"+ strFl4fNA(meanSensOfEp, self.NA_PATTERN) +"\t=> TruePos/RealPos") self.logger.print3(logStrClass + "\t mean specificity of epoch:\t"+ strFl4fNA(meanSpecOfEp, self.NA_PATTERN) +"\t=> TrueNeg/RealNeg") self.logger.print3(logStrClass + "\t mean Dice of epoch: \t"+ strFl4fNA(meanDscOfEp, self.NA_PATTERN) ) #Visualised in my scripts: self.logger.print3(logStrClass + "\t mean accuracy of each subepoch:\t"+ strListFl4fNA(meanAccPerSubep, self.NA_PATTERN) ) self.logger.print3(logStrClass + "\t mean sensitivity of each subepoch:\t" + strListFl4fNA(meanSensPerSubep, self.NA_PATTERN) ) self.logger.print3(logStrClass + "\t mean specificity of each subepoch:\t" + strListFl4fNA(meanSpecPerSubep, self.NA_PATTERN) ) self.logger.print3(logStrClass + "\t mean Dice of each subepoch: \t" + strListFl4fNA(meanDscPerSubep, self.NA_PATTERN) ) self.logger.print3( ">>>>>>>>>>>>>>>>>>>>>>>>> End Of Accuracy Report at the end of Epoch <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ) self.logger.print3( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" )