Class ClassificationMetrics

java.lang.Object
smile.validation.ClassificationMetrics
All Implemented Interfaces:
Serializable

public class ClassificationMetrics extends Object implements Serializable
The classification validation metrics.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double
    The accuracy on validation data.
    final double
    The AUC on validation data.
    final double
    The cross entropy on validation data.
    final int
    The number of errors.
    final double
    The F-1 score on validation data.
    final double
    The time in milliseconds of fitting the model.
    final double
    The log loss on validation data.
    final double
    The Matthews correlation coefficient on validation data.
    final double
    The precision on validation data.
    final double
    The time in milliseconds of scoring the validation data.
    final double
    The sensitivity on validation data.
    final int
    The validation data size.
    final double
    The specificity on validation data.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy)
    Constructor.
    ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy, double crossentropy)
    Constructor of multiclass soft classifier validation.
    ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy, double sensitivity, double specificity, double precision, double f1, double mcc)
    Constructor of binary classifier validation.
    ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy, double sensitivity, double specificity, double precision, double f1, double mcc, double auc, double logloss)
    Constructor of binary soft classifier validation.
    ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy, double sensitivity, double specificity, double precision, double f1, double mcc, double auc, double logloss, double crossentropy)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    of(double fitTime, double scoreTime, int[] truth, int[] prediction)
    Computes the classification metrics.
    of(double fitTime, double scoreTime, int[] truth, int[] prediction, double[][] posteriori)
    Computes the soft classification metrics.
    of(double fitTime, M model, Formula formula, DataFrame test)
    Validates a model on a test data.
    static <T, M extends Classifier<T>>
    ClassificationMetrics
    of(double fitTime, M model, T[] testx, int[] testy)
    Validates a model on a test data.
    of(M model, Formula formula, DataFrame test)
    Validates a model on a test data.
    static <T, M extends Classifier<T>>
    ClassificationMetrics
    of(M model, T[] testx, int[] testy)
    Validates a model on a test data.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • fitTime

      public final double fitTime
      The time in milliseconds of fitting the model.
    • scoreTime

      public final double scoreTime
      The time in milliseconds of scoring the validation data.
    • size

      public final int size
      The validation data size.
    • error

      public final int error
      The number of errors.
    • accuracy

      public final double accuracy
      The accuracy on validation data.
    • sensitivity

      public final double sensitivity
      The sensitivity on validation data.
    • specificity

      public final double specificity
      The specificity on validation data.
    • precision

      public final double precision
      The precision on validation data.
    • f1

      public final double f1
      The F-1 score on validation data.
    • mcc

      public final double mcc
      The Matthews correlation coefficient on validation data.
    • auc

      public final double auc
      The AUC on validation data.
    • logloss

      public final double logloss
      The log loss on validation data.
    • crossentropy

      public final double crossentropy
      The cross entropy on validation data.
  • Constructor Details

    • ClassificationMetrics

      public ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy)
      Constructor.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      scoreTime - the time in milliseconds of scoring the validation data.
      size - the validation data size.
      error - the number of errors.
      accuracy - the accuracy on validation data.
    • ClassificationMetrics

      public ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy, double crossentropy)
      Constructor of multiclass soft classifier validation.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      scoreTime - the time in milliseconds of scoring the validation data.
      size - the validation data size.
      error - the number of errors.
      accuracy - the accuracy on validation data.
      crossentropy - the cross entropy on validation data.
    • ClassificationMetrics

      public ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy, double sensitivity, double specificity, double precision, double f1, double mcc)
      Constructor of binary classifier validation.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      scoreTime - the time in milliseconds of scoring the validation data.
      size - the validation data size.
      error - the number of errors.
      accuracy - the accuracy on validation data.
      sensitivity - the sensitivity on validation data.
      specificity - the specificity on validation data.
      precision - the precision on validation data.
      f1 - the F-1 score on validation data.
      mcc - the Matthews correlation coefficient on validation data.
    • ClassificationMetrics

      public ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy, double sensitivity, double specificity, double precision, double f1, double mcc, double auc, double logloss)
      Constructor of binary soft classifier validation.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      scoreTime - the time in milliseconds of scoring the validation data.
      size - the validation data size.
      error - the number of errors.
      accuracy - the accuracy on validation data.
      sensitivity - the sensitivity on validation data.
      specificity - the specificity on validation data.
      precision - the precision on validation data.
      f1 - the F-1 score on validation data.
      mcc - the Matthews correlation coefficient on validation data.
      auc - the AUC on validation data.
      logloss - the log loss on validation data.
    • ClassificationMetrics

      public ClassificationMetrics(double fitTime, double scoreTime, int size, int error, double accuracy, double sensitivity, double specificity, double precision, double f1, double mcc, double auc, double logloss, double crossentropy)
      Constructor.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      scoreTime - the time in milliseconds of scoring the validation data.
      size - the validation data size.
      error - the number of errors.
      accuracy - the accuracy on validation data.
      sensitivity - the sensitivity on validation data.
      specificity - the specificity on validation data.
      precision - the precision on validation data.
      f1 - the F-1 score on validation data.
      mcc - the Matthews correlation coefficient on validation data.
      auc - the AUC on validation data.
      logloss - the log loss on validation data.
      crossentropy - the cross entropy on validation data.
  • Method Details

    • toString

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

      public static ClassificationMetrics of(double fitTime, double scoreTime, int[] truth, int[] prediction)
      Computes the classification metrics.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      scoreTime - the time in milliseconds of scoring the validation data.
      truth - the ground truth.
      prediction - the predictions.
      Returns:
      the classification metrics.
    • of

      public static ClassificationMetrics of(double fitTime, double scoreTime, int[] truth, int[] prediction, double[][] posteriori)
      Computes the soft classification metrics.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      scoreTime - the time in milliseconds of scoring the validation data.
      truth - the ground truth.
      prediction - the predictions.
      posteriori - the posteriori probabilities of predictions.
      Returns:
      the classification metrics.
    • of

      public static <T, M extends Classifier<T>> ClassificationMetrics of(M model, T[] testx, int[] testy)
      Validates a model on a test data.
      Type Parameters:
      T - the data type of samples.
      M - the model type.
      Parameters:
      model - the model.
      testx - the validation data.
      testy - the class labels of validation data.
      Returns:
      the validation results.
    • of

      public static <T, M extends Classifier<T>> ClassificationMetrics of(double fitTime, M model, T[] testx, int[] testy)
      Validates a model on a test data.
      Type Parameters:
      T - the data type of samples.
      M - the model type.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      model - the model.
      testx - the validation data.
      testy - the class labels of validation data.
      Returns:
      the validation results.
    • of

      public static <M extends DataFrameClassifier> ClassificationMetrics of(M model, Formula formula, DataFrame test)
      Validates a model on a test data.
      Type Parameters:
      M - the model type.
      Parameters:
      model - the model.
      formula - the model formula.
      test - the validation data.
      Returns:
      the validation results.
    • of

      public static <M extends DataFrameClassifier> ClassificationMetrics of(double fitTime, M model, Formula formula, DataFrame test)
      Validates a model on a test data.
      Type Parameters:
      M - the model type.
      Parameters:
      fitTime - the time in milliseconds of fitting the model.
      model - the model.
      formula - the model formula.
      test - the validation data.
      Returns:
      the validation results.