001/*
002 * Copyright (c) 2015-2020, Oracle and/or its affiliates. All rights reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.tribuo.anomaly.evaluation;
018
019import org.tribuo.anomaly.Event;
020import org.tribuo.evaluation.Evaluation;
021
022/**
023 * An {@link Evaluation} for anomaly detection {@link Event}s.
024 */
025public interface AnomalyEvaluation extends Evaluation<Event> {
026
027    /**
028     * Returns the number of false positives, i.e., expected events classified as anomalous.
029     * @return The number of false positives.
030     */
031    long getFalsePositives();
032
033    /**
034     * Returns the number of true positives, i.e., anomalous events classified as anomalous.
035     * @return The number of true positives.
036     */
037    long getTruePositives();
038
039    /**
040     * Returns the number of true negatives, i.e., expected events classified as events.
041     * @return The number of true negatives.
042     */
043    long getTrueNegatives();
044
045    /**
046     * Returns the number of false negatives, i.e., anomalous events classified as expected.
047     * <p>
048     * These are the ones you don't want.
049     * @return The number of false negatives.
050     */
051    long getFalseNegatives();
052
053    /**
054     * Returns the precision of the anomalous events, i.e., true positives divided by the number of predicted positives.
055     * @return The precision.
056     */
057    double getPrecision();
058
059    /**
060     * Returns the recall of the anomalous events, i.e., true positives divided by the number of positives.
061     * @return The recall.
062     */
063    double getRecall();
064
065    /**
066     * Returns the F_1 score of the anomalous events, i.e., the harmonic mean of the precision and the recall.
067     * @return The F_1 score.
068     */
069    double getF1();
070
071    /**
072     * Returns a confusion matrix formatted String for display.
073     * @return The confusion matrix in a String.
074     */
075    String confusionString();
076
077}