Package smile.validation
Interface LOOCV
public interface LOOCV
Leave-one-out cross validation. LOOCV uses a single observation
from the original sample as the validation data, and the remaining
observations as the training data. This is repeated such that each
observation in the sample is used once as the validation data. This is
the same as a K-fold cross-validation with K being equal to the number of
observations in the original sample. Leave-one-out cross-validation is
usually very expensive from a computational point of view because of the
large number of times the training process is repeated.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassificationMetrics
classification
(Formula formula, DataFrame data, BiFunction<Formula, DataFrame, DataFrameClassifier> trainer) Runs leave-one-out cross validation tests.static <T,
M extends Classifier<T>>
ClassificationMetricsclassification
(T[] x, int[] y, BiFunction<T[], int[], M> trainer) Runs leave-one-out cross validation tests.static int[][]
of
(int n) Returns the training sample index for each round.static RegressionMetrics
regression
(Formula formula, DataFrame data, BiFunction<Formula, DataFrame, DataFrameRegression> trainer) Runs leave-one-out cross validation tests.static <T,
M extends Regression<T>>
RegressionMetricsregression
(T[] x, double[] y, BiFunction<T[], double[], M> trainer) Runs leave-one-out cross validation tests.
-
Method Details
-
of
static int[][] of(int n) Returns the training sample index for each round.- Parameters:
n
- the number of samples.- Returns:
- The index of training instances for each round. The left one of i-th round is i-th sample.
-
classification
static <T,M extends Classifier<T>> ClassificationMetrics classification(T[] x, int[] y, BiFunction<T[], int[], M> trainer) Runs leave-one-out cross validation tests.- Type Parameters:
T
- the data type of samples.M
- the model type.- Parameters:
x
- the training data.y
- the class labels of training data.trainer
- the lambda to train the model.- Returns:
- the validation results.
-
classification
static ClassificationMetrics classification(Formula formula, DataFrame data, BiFunction<Formula, DataFrame, DataFrameClassifier> trainer) Runs leave-one-out cross validation tests.- Parameters:
formula
- the model formula.data
- the training data.trainer
- the lambda to train the model.- Returns:
- the validation results.
-
regression
static <T,M extends Regression<T>> RegressionMetrics regression(T[] x, double[] y, BiFunction<T[], double[], M> trainer) Runs leave-one-out cross validation tests.- Type Parameters:
T
- the data type of samples.M
- the model type.- Parameters:
x
- the training data.y
- the responsible variable of training data.trainer
- the lambda to train the model.- Returns:
- the validation results.
-
regression
static RegressionMetrics regression(Formula formula, DataFrame data, BiFunction<Formula, DataFrame, DataFrameRegression> trainer) Runs leave-one-out cross validation tests.- Parameters:
formula
- the model formula.data
- the training data.trainer
- the lambda to train the model.- Returns:
- the validation results.
-