Record Class ClassificationMetrics

java.lang.Object
java.lang.Record
smile.validation.ClassificationMetrics
Record Components:
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.
All Implemented Interfaces:
Serializable

public record 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) extends Record implements Serializable
The classification validation metrics.
See Also:
  • 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)
    Creates an instance of a ClassificationMetrics record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the value of the accuracy record component.
    double
    auc()
    Returns the value of the auc record component.
    double
    Returns the value of the crossentropy record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns the value of the error record component.
    double
    f1()
    Returns the value of the f1 record component.
    double
    Returns the value of the fitTime record component.
    final int
    Returns a hash code value for this object.
    double
    Returns the value of the logloss record component.
    double
    mcc()
    Returns the value of the mcc record component.
    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.
    double
    Returns the value of the precision record component.
    double
    Returns the value of the scoreTime record component.
    double
    Returns the value of the sensitivity record component.
    int
    Returns the value of the size record component.
    double
    Returns the value of the specificity record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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)
      Creates an instance of a ClassificationMetrics record class.
      Parameters:
      fitTime - the value for the fitTime record component
      scoreTime - the value for the scoreTime record component
      size - the value for the size record component
      error - the value for the error record component
      accuracy - the value for the accuracy record component
      sensitivity - the value for the sensitivity record component
      specificity - the value for the specificity record component
      precision - the value for the precision record component
      f1 - the value for the f1 record component
      mcc - the value for the mcc record component
      auc - the value for the auc record component
      logloss - the value for the logloss record component
      crossentropy - the value for the crossentropy record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this 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.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • fitTime

      public double fitTime()
      Returns the value of the fitTime record component.
      Returns:
      the value of the fitTime record component
    • scoreTime

      public double scoreTime()
      Returns the value of the scoreTime record component.
      Returns:
      the value of the scoreTime record component
    • size

      public int size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • error

      public int error()
      Returns the value of the error record component.
      Returns:
      the value of the error record component
    • accuracy

      public double accuracy()
      Returns the value of the accuracy record component.
      Returns:
      the value of the accuracy record component
    • sensitivity

      public double sensitivity()
      Returns the value of the sensitivity record component.
      Returns:
      the value of the sensitivity record component
    • specificity

      public double specificity()
      Returns the value of the specificity record component.
      Returns:
      the value of the specificity record component
    • precision

      public double precision()
      Returns the value of the precision record component.
      Returns:
      the value of the precision record component
    • f1

      public double f1()
      Returns the value of the f1 record component.
      Returns:
      the value of the f1 record component
    • mcc

      public double mcc()
      Returns the value of the mcc record component.
      Returns:
      the value of the mcc record component
    • auc

      public double auc()
      Returns the value of the auc record component.
      Returns:
      the value of the auc record component
    • logloss

      public double logloss()
      Returns the value of the logloss record component.
      Returns:
      the value of the logloss record component
    • crossentropy

      public double crossentropy()
      Returns the value of the crossentropy record component.
      Returns:
      the value of the crossentropy record component