public double getAnomalyScore ( Instance inst ) { double error = 0.0 ; if ( ! this . reset ) { double [ ] attributeValues = new double [ inst . numAttributes ( ) - 1 ] ; for ( int i = 0 ; i < attributeValues . length ; i ++ ) { attributeValues [ i ] = inst . value ( i ) ; } RealMatrix input = new Array2DRowRealMatrix ( attributeValues ) ; RealMatrix output = secondLayer ( firstLayer ( input ) ) ; for ( int i = 0 ; i < this . numAttributes ; i ++ ) { error += 0.5 * Math . pow ( output . getEntry ( i , 0 ) - input . getEntry ( i , 0 ) , 2.0 ) ; } } return error ; }
Returns the squared error between the input value and the reconstructed value as the anomaly score for the argument instance .