Package smile.validation
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
ConstructorDescriptionClassificationMetrics
(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 aClassificationMetrics
record class. -
Method Summary
Modifier and TypeMethodDescriptiondouble
accuracy()
Returns the value of theaccuracy
record component.double
auc()
Returns the value of theauc
record component.double
Returns the value of thecrossentropy
record component.final boolean
Indicates whether some other object is "equal to" this one.int
error()
Returns the value of theerror
record component.double
f1()
Returns the value of thef1
record component.double
fitTime()
Returns the value of thefitTime
record component.final int
hashCode()
Returns a hash code value for this object.double
logloss()
Returns the value of thelogloss
record component.double
mcc()
Returns the value of themcc
record component.static ClassificationMetrics
of
(double fitTime, double scoreTime, int[] truth, int[] prediction) Computes the classification metrics.static ClassificationMetrics
of
(double fitTime, double scoreTime, int[] truth, int[] prediction, double[][] posteriori) Computes the soft classification metrics.static <M extends DataFrameClassifier>
ClassificationMetricsValidates a model on a test data.static <T,
M extends Classifier<T>>
ClassificationMetricsof
(double fitTime, M model, T[] testx, int[] testy) Validates a model on a test data.static <M extends DataFrameClassifier>
ClassificationMetricsValidates a model on a test data.static <T,
M extends Classifier<T>>
ClassificationMetricsof
(M model, T[] testx, int[] testy) Validates a model on a test data.double
Returns the value of theprecision
record component.double
Returns the value of thescoreTime
record component.double
Returns the value of thesensitivity
record component.int
size()
Returns the value of thesize
record component.double
Returns the value of thespecificity
record component.toString()
Returns a string representation of this record class.
-
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 aClassificationMetrics
record class.- Parameters:
fitTime
- the value for thefitTime
record componentscoreTime
- the value for thescoreTime
record componentsize
- the value for thesize
record componenterror
- the value for theerror
record componentaccuracy
- the value for theaccuracy
record componentsensitivity
- the value for thesensitivity
record componentspecificity
- the value for thespecificity
record componentprecision
- the value for theprecision
record componentf1
- the value for thef1
record componentmcc
- the value for themcc
record componentauc
- the value for theauc
record componentlogloss
- the value for thelogloss
record componentcrossentropy
- the value for thecrossentropy
record component
-
-
Method Details
-
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. -
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. -
equals
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 '=='. -
fitTime
public double fitTime()Returns the value of thefitTime
record component.- Returns:
- the value of the
fitTime
record component
-
scoreTime
public double scoreTime()Returns the value of thescoreTime
record component.- Returns:
- the value of the
scoreTime
record component
-
size
public int size()Returns the value of thesize
record component.- Returns:
- the value of the
size
record component
-
error
public int error()Returns the value of theerror
record component.- Returns:
- the value of the
error
record component
-
accuracy
public double accuracy()Returns the value of theaccuracy
record component.- Returns:
- the value of the
accuracy
record component
-
sensitivity
public double sensitivity()Returns the value of thesensitivity
record component.- Returns:
- the value of the
sensitivity
record component
-
specificity
public double specificity()Returns the value of thespecificity
record component.- Returns:
- the value of the
specificity
record component
-
precision
public double precision()Returns the value of theprecision
record component.- Returns:
- the value of the
precision
record component
-
f1
public double f1()Returns the value of thef1
record component.- Returns:
- the value of the
f1
record component
-
mcc
public double mcc()Returns the value of themcc
record component.- Returns:
- the value of the
mcc
record component
-
auc
public double auc()Returns the value of theauc
record component.- Returns:
- the value of the
auc
record component
-
logloss
public double logloss()Returns the value of thelogloss
record component.- Returns:
- the value of the
logloss
record component
-
crossentropy
public double crossentropy()Returns the value of thecrossentropy
record component.- Returns:
- the value of the
crossentropy
record component
-