Class Precision

java.lang.Object
smile.validation.metric.Precision
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<int[],int[]>, ClassificationMetric

public class Precision extends Object implements ClassificationMetric
The precision or positive predictive value (PPV) is ratio of true positives to combined true and false positives, which is different from sensitivity.
     PPV = TP / (TP + FP)
 
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Precision
    Default instance.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
    Precision(Averaging strategy)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    of(int[] truth, int[] prediction)
    Calculates the precision of binary classification.
    static double
    of(int[] truth, int[] prediction, Averaging strategy)
    Calculates the precision.
    double
    score(int[] truth, int[] prediction)
    Returns a score to measure the quality of classification.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface smile.validation.metric.ClassificationMetric

    applyAsDouble
  • Field Details

    • instance

      public static final Precision instance
      Default instance.
  • Constructor Details

    • Precision

      public Precision()
      Constructor.
    • Precision

      public Precision(Averaging strategy)
      Constructor.
      Parameters:
      strategy - The aggregating strategy for multi-classes.
  • Method Details

    • score

      public double score(int[] truth, int[] prediction)
      Description copied from interface: ClassificationMetric
      Returns a score to measure the quality of classification.
      Specified by:
      score in interface ClassificationMetric
      Parameters:
      truth - the true class labels.
      prediction - the predicted class labels.
      Returns:
      the metric.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • of

      public static double of(int[] truth, int[] prediction)
      Calculates the precision of binary classification.
      Parameters:
      truth - the ground truth.
      prediction - the prediction.
      Returns:
      the metric.
    • of

      public static double of(int[] truth, int[] prediction, Averaging strategy)
      Calculates the precision.
      Parameters:
      truth - the ground truth.
      prediction - the prediction.
      strategy - The aggregating strategy for multi-classes.
      Returns:
      the metric.