Package smile.validation
Class ClassificationValidation<M>
java.lang.Object
smile.validation.ClassificationValidation<M>
- Type Parameters:
M
- the model type.
- All Implemented Interfaces:
Serializable
Classification model validation results.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal ConfusionMatrix
The confusion matrix.final ClassificationMetrics
The classification metrics.final M
The model.final double[][]
The posteriori probability of prediction if the model is a soft classifier.final int[]
The model prediction.final int[]
The true class labels of validation data. -
Constructor Summary
ConstructorDescriptionClassificationValidation
(M model, double fitTime, double scoreTime, int[] truth, int[] prediction) Constructor.ClassificationValidation
(M model, double fitTime, double scoreTime, int[] truth, int[] prediction, double[][] posteriori) Constructor of soft classifier validation. -
Method Summary
Modifier and TypeMethodDescriptionstatic <M extends DataFrameClassifier>
ClassificationValidation<M> Trains and validates a model on a train/validation split.static <M extends DataFrameClassifier>
ClassificationValidations<M> Trains and validates a model on multiple train/validation split.static <T,
M extends Classifier<T>>
ClassificationValidations<M> of
(Bag[] bags, T[] x, int[] y, BiFunction<T[], int[], M> trainer) Trains and validates a model on multiple train/validation split.static <T,
M extends Classifier<T>>
ClassificationValidation<M> of
(T[] x, int[] y, T[] testx, int[] testy, BiFunction<T[], int[], M> trainer) Trains and validates a model on a train/validation split.toString()
-
Field Details
-
model
The model. -
truth
public final int[] truthThe true class labels of validation data. -
prediction
public final int[] predictionThe model prediction. -
posteriori
public final double[][] posterioriThe posteriori probability of prediction if the model is a soft classifier. -
confusion
The confusion matrix. -
metrics
The classification metrics.
-
-
Constructor Details
-
ClassificationValidation
public ClassificationValidation(M model, double fitTime, double scoreTime, int[] truth, int[] prediction) Constructor.- Parameters:
model
- the model.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.
-
ClassificationValidation
public ClassificationValidation(M model, double fitTime, double scoreTime, int[] truth, int[] prediction, double[][] posteriori) Constructor of soft classifier validation.- Parameters:
model
- the model.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.
-
-
Method Details
-
toString
-
of
public static <T,M extends Classifier<T>> ClassificationValidation<M> of(T[] x, int[] y, T[] testx, int[] testy, BiFunction<T[], int[], M> trainer) Trains and validates a model on a train/validation split.- Type Parameters:
T
- the data type of samples.M
- the model type.- Parameters:
x
- the training data.y
- the class labels of training data.testx
- the validation data.testy
- the class labels of validation data.trainer
- the lambda to train the model.- Returns:
- the validation results.
-
of
public static <T,M extends Classifier<T>> ClassificationValidations<M> of(Bag[] bags, T[] x, int[] y, BiFunction<T[], int[], M> trainer) Trains and validates a model on multiple train/validation split.- Type Parameters:
T
- the data type of samples.M
- the model type.- Parameters:
bags
- the data splits.x
- the training data.y
- the class labels.trainer
- the lambda to train the model.- Returns:
- the validation results.
-
of
public static <M extends DataFrameClassifier> ClassificationValidation<M> of(Formula formula, DataFrame train, DataFrame test, BiFunction<Formula, DataFrame, M> trainer) Trains and validates a model on a train/validation split.- Type Parameters:
M
- the model type.- Parameters:
formula
- the model formula.train
- the training data.test
- the validation data.trainer
- the lambda to train the model.- Returns:
- the validation results.
-
of
public static <M extends DataFrameClassifier> ClassificationValidations<M> of(Bag[] bags, Formula formula, DataFrame data, BiFunction<Formula, DataFrame, M> trainer) Trains and validates a model on multiple train/validation split.- Type Parameters:
M
- the model type.- Parameters:
bags
- the data splits.formula
- the model formula.data
- the data.trainer
- the lambda to train the model.- Returns:
- the validation results.
-