code: public static <T> double loocv(ClassifierTrainer<T> trainer, T[] x, int[] y) {
          int m = 0;
          int n = x.length;
          
          LOOCV loocv = new LOOCV(n);
          for (int i = 0; i < n; i++) {
              T[] trainx = Math.slice(x, loocv.train[i]);
              int[] trainy = Math.slice(y, loocv.train[i]);
              
              Classifier<T> classifier = trainer.train(trainx, trainy);
  
              if (classifier.predict(x[loocv.test[i]]) == y[loocv.test[i]]) {
                  m++;
              }
          }
          
          return (double) m / n;
      }
docs: Leave-one-out cross validation of a classification model.
  
  @param <T> the data type of input objects.
  @param trainer a classifier trainer that is properly parameterized.
  @param x the test data set.
  @param y the test data labels.
  @return the accuracy on test dataset