@ Override public void merge ( ROC other ) { if ( this . thresholdSteps != other . thresholdSteps ) { throw new UnsupportedOperationException ( "Cannot merge ROC instances with different numbers of threshold steps (" + this . thresholdSteps + " vs. " + other . thresholdSteps + ")" ) ; } this . countActualPositive += other . countActualPositive ; this . countActualNegative += other . countActualNegative ; this . auc = null ; this . auprc = null ; this . rocCurve = null ; this . prCurve = null ; if ( isExact ) { if ( other . exampleCount == 0 ) { return ; } if ( this . exampleCount == 0 ) { this . exampleCount = other . exampleCount ; this . probAndLabel = other . probAndLabel ; return ; } if ( this . exampleCount + other . exampleCount > this . probAndLabel . size ( 0 ) ) { //Allocate new array val newSize = this . probAndLabel . size ( 0 ) + Math . max ( other . probAndLabel . size ( 0 ) , exactAllocBlockSize ) ; INDArray newProbAndLabel = Nd4j . create ( DataType . DOUBLE , newSize , 2 ) ; newProbAndLabel . put ( new INDArrayIndex [ ] { interval ( 0 , exampleCount ) , all ( ) } , probAndLabel . get ( interval ( 0 , exampleCount ) , all ( ) ) ) ; probAndLabel = newProbAndLabel ; } INDArray toPut = other . probAndLabel . get ( interval ( 0 , other . exampleCount ) , all ( ) ) ; probAndLabel . put ( new INDArrayIndex [ ] { interval ( exampleCount , exampleCount + other . exampleCount ) , all ( ) } , toPut ) ; } else { for ( Double d : this . counts . keySet ( ) ) { CountsForThreshold cft = this . counts . get ( d ) ; CountsForThreshold otherCft = other . counts . get ( d ) ; cft . countTruePositive += otherCft . countTruePositive ; cft . countFalsePositive += otherCft . countFalsePositive ; } } this . exampleCount += other . exampleCount ; }
Merge this ROC instance with another . This ROC instance is modified by adding the stats from the other instance .