Signed-off-by: Po-Wei Wang <xflash96@gmail.com>
void cross_validation(const problem *prob, const parameter *param, int nr_fold, double *target)
{
int i;
- int *fold_start = Malloc(int,nr_fold+1);
+ int *fold_start;
int l = prob->l;
int *perm = Malloc(int,l);
-
+ if (nr_fold > l)
+ {
+ nr_fold = l;
+ fprintf(stderr,"WARNING: # folds > # data. Will use # folds = # data instead (i.e., leave-one-out cross validation)\n");
+ }
+ fold_start = Malloc(int,nr_fold+1);
for(i=0;i<l;i++) perm[i]=i;
for(i=0;i<l;i++)
{