Class RegressionValidation<M>

java.lang.Object
smile.validation.RegressionValidation<M>
Type Parameters:
M - the regression model type.
All Implemented Interfaces:
Serializable

public class RegressionValidation<M> extends Object implements Serializable
Regression model validation results.
See Also:
  • Field Details

    • model

      public final M model
      The model.
    • truth

      public final double[] truth
      The true response variable of validation data.
    • prediction

      public final double[] prediction
      The model prediction.
    • metrics

      public final RegressionMetrics 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

      public String toString()
      Overrides:
      toString in class Object
    • 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.