def compute(self, activeColumns, predictedColumns,<EOL>inputValue=None, timestamp=None):
<EOL>anomalyScore = computeRawAnomalyScore(activeColumns, predictedColumns)<EOL>if self._mode == Anomaly.MODE_PURE:<EOL><INDENT>score = anomalyScore<EOL><DEDENT>elif self._mode == Anomaly.MODE_LIKELIHOOD:<EOL><INDENT>if inputValue is None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>probability = self._likelihood.anomalyProbability(<EOL>inputValue, anomalyScore, timestamp)<EOL>score = <NUM_LIT:1> - probability<EOL><DEDENT>elif self._mode == Anomaly.MODE_WEIGHTED:<EOL><INDENT>probability = self._likelihood.anomalyProbability(<EOL>inputValue, anomalyScore, timestamp)<EOL>score = anomalyScore * (<NUM_LIT:1> - probability)<EOL><DEDENT>if self._movingAverage is not None:<EOL><INDENT>score = self._movingAverage.next(score)<EOL><DEDENT>if self._binaryThreshold is not None:<EOL><INDENT>if score >= self._binaryThreshold:<EOL><INDENT>score = <NUM_LIT:1.0><EOL><DEDENT>else:<EOL><INDENT>score = <NUM_LIT:0.0><EOL><DEDENT><DEDENT>return score<EOL>
Compute the anomaly score as the percent of active columns not predicted.

        :param activeColumns: array of active column indices
        :param predictedColumns: array of columns indices predicted in this step
                                 (used for anomaly in step T+1)
        :param inputValue: (optional) value of current input to encoders
                                      (eg "cat" for category encoder)
                                      (used in anomaly-likelihood)
        :param timestamp: (optional) date timestamp when the sample occured
                                     (used in anomaly-likelihood)
        :returns: the computed anomaly score; float 0..1