code: public static <T> double loocv(RegressionTrainer<T> trainer, T[] x, double[] y, RegressionMeasure measure) {
          int n = x.length;
          double[] predictions = new double[n];
          
          LOOCV loocv = new LOOCV(n);
          for (int i = 0; i < n; i++) {
              T[] trainx = Math.slice(x, loocv.train[i]);
              double[] trainy = Math.slice(y, loocv.train[i]);
              
              Regression<T> model = trainer.train(trainx, trainy);
  
              predictions[loocv.test[i]] = model.predict(x[loocv.test[i]]);
          }
          
          return measure.measure(y, predictions);
      }
docs: Leave-one-out cross validation of a regression model.
  
  @param <T> the data type of input objects.
  @param trainer a regression model trainer that is properly parameterized.
  @param x the test data set.
  @param y the test data response values.
  @param measure the performance measure of regression.
  @return the test results with the same size of order of measures