Record Class RegressionValidation<M>
java.lang.Object
java.lang.Record
smile.validation.RegressionValidation<M>
- Type Parameters:
M- The regression model type.- Record Components:
model- The regression model.truth- The ground true of validation data.prediction- The model prediction.metrics- The regression metrics.
- All Implemented Interfaces:
Serializable
public record RegressionValidation<M>(M model, double[] truth, double[] prediction, RegressionMetrics metrics)
extends Record
implements Serializable
Regression model validation results.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRegressionValidation(M model, double[] truth, double[] prediction, RegressionMetrics metrics) Creates an instance of aRegressionValidationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.metrics()Returns the value of themetricsrecord component.model()Returns the value of themodelrecord component.static <M extends DataFrameRegression>
RegressionValidation<M> Trains and validates a model on a train/validation split.static <M extends DataFrameRegression>
RegressionValidations<M> Trains and validates a model on multiple train/validation split.static <T, M extends Regression<T>>
RegressionValidations<M> of(Bag[] bags, T[] x, double[] y, BiFunction<T[], double[], M> trainer) Trains and validates a model on multiple train/validation split.static <T, M extends Regression<T>>
RegressionValidation<M> of(T[] x, double[] y, T[] testx, double[] testy, BiFunction<T[], double[], M> trainer) Trains and validates a model on a train/validation split.double[]Returns the value of thepredictionrecord component.toString()Returns a string representation of this record class.double[]truth()Returns the value of thetruthrecord component.
-
Constructor Details
-
RegressionValidation
public RegressionValidation(M model, double[] truth, double[] prediction, RegressionMetrics metrics) Creates an instance of aRegressionValidationrecord class.- Parameters:
model- the value for themodelrecord componenttruth- the value for thetruthrecord componentprediction- the value for thepredictionrecord componentmetrics- the value for themetricsrecord component
-
-
Method Details
-
toString
-
of
public static <T, M extends Regression<T>> RegressionValidation<M> of(T[] x, double[] y, T[] testx, double[] testy, BiFunction<T[], double[], 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 responsible variable of training data.testx- the validation data.testy- the responsible variable of validation data.trainer- the lambda to train the model.- Returns:
- the validation results.
-
of
public static <T, M extends Regression<T>> RegressionValidations<M> of(Bag[] bags, T[] x, double[] y, BiFunction<T[], double[], 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 responsible variable.trainer- the lambda to train the model.- Returns:
- the validation results.
-
of
public static <M extends DataFrameRegression> RegressionValidation<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 DataFrameRegression> RegressionValidations<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.
-
hashCode
-
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 withObjects::equals(Object,Object). -
model
-
truth
-
prediction
public double[] prediction()Returns the value of thepredictionrecord component.- Returns:
- the value of the
predictionrecord component
-
metrics
-