Package smile.validation
Class RegressionValidation<M>
java.lang.Object
smile.validation.RegressionValidation<M>
- Type Parameters:
M
- the regression model type.
- All Implemented Interfaces:
Serializable
Regression model validation results.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal RegressionMetrics
The regression metrics.final M
The model.final double[]
The model prediction.final double[]
The true response variable of validation data. -
Constructor Summary
ConstructorDescriptionRegressionValidation
(M model, double[] truth, double[] prediction, RegressionMetrics metrics) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic <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.toString()
-
Field Details
-
model
The model. -
truth
public final double[] truthThe true response variable of validation data. -
prediction
public final double[] predictionThe model prediction. -
metrics
The regression metrics.
-
-
Constructor Details
-
RegressionValidation
public RegressionValidation(M model, double[] truth, double[] prediction, RegressionMetrics metrics) Constructor.- Parameters:
model
- the model.truth
- the ground truth.prediction
- the predictions.metrics
- the validation metrics.
-
-
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.
-