# Resampling Methods

## k-fold

`mlpy.``kfold`(nsamples, sets, rseed=0, indexes=None)

  K-fold Resampling Method.

  Input

  > - nsamples - [integer] number of samples
  > - sets - [integer] number of subsets (= number of tr/ts pairs)
  > - rseed - [integer] random seed
  > - indexes - [list integer] source indexes (None for [0, nsamples-1])

  Output

  > - idx - list of sets tuples: ([training indexes], [test indexes])

`mlpy.``kfoldS`(cl, sets, rseed=0, indexes=None)

  Stratified K-fold Resampling Method.

  Input

  > - cl - [list (1 or -1)] class label
  > - sets - [integer] number of subsets (= number of tr/ts pairs)
  > - rseed - [integer] random seed
  > - indexes - [list integer] source indexes (None for [0, nsamples-1])

  Output

  > - idx - list of sets tuples: ([training indexes], [test indexes])

## Monte Carlo

`mlpy.``montecarlo`(nsamples, pairs, sets, rseed=0, indexes=None)

  Monte Carlo Resampling Method.

  Input

  > - nsamples - [integer] number of samples
  > - pairs - [integer] number of tr/ts pairs
  > - sets - [integer] 1/(fraction of data in test sets)
  > - rseed - [integer] random seed
  > - indexes - [list integer] source indexes (None for [0, nsamples-1])

  Output

  > - idx - list of pairs tuples: ([training indexes], [test indexes])

`mlpy.``montecarloS`(cl, pairs, sets, rseed=0, indexes=None)

  Stratified Monte Carlo Resampling Method.

  Input

  > - cl - [list (1 or -1)] class label
  > - pairs - [integer] number of tr/ts pairs
  > - sets - [integer] 1/(fraction of data in test sets)
  > - rseed - [integer] random seed
  > - indexes - [list integer] source indexes (None for [0, nsamples-1])

  Output

  > - idx - list of pairs tuples: ([training indexes], [test indexes])

## Leave-one-out

`mlpy.``leaveoneout`(nsamples, indexes=None)

  Leave-one-out Resampling Method.

  Input

  > - nsamples - [integer] number of samples
  > - indexes - [list integer] source indexes (None for [0, nsamples-1])

  Output

  > - idx - list of nsamples tuples: ([training indexes], [test indexes])

## All Combinations

`mlpy.``allcombinations`(cl, sets, indexes=None)

  All Combinations Resampling Method.

  Input

  > - cl - [list (1 or -1)] class label
  > - sets - [integer] number of subset
  > - indexes - [list integer] source indexes (None for [0, nsamples-1])

  Output

  > - idx - list of tuples: ([training indexes], [test indexes])

## Manual Resampling

`mlpy.``manresampling`(cl, pairs, trp, trn, tsp, tsn, rseed=0)

  Manual Resampling.

  Input

  > - cl - [list (1 or -1)] class label
  > - pairs - [integer] number of tr/ts pairs
  > - trp - [integer] number of positive samples in training
  > - trn - [integer] number of negative samples in training
  > - tsp - [integer] number of positive samples in test
  > - tsn - [integer] number of negative samples in test

  Output

  > - idx - list of pairs tuples: ([training indexes], [test indexes])

## Resampling File

`mlpy.``resamplingfile`(nsamples, file, sep='\t')

  Resampling file from file.

  Returns a list of tuples: ([training indexes],[test indexes])

  Read a file in the form:

      [test indexes 'sep'-separated for the first  replicate]
      [test indexes 'sep'-separated for the second replicate]
                              .
                              .
                              .
      [test indexes 'sep'-separated for the last   replicate]

  where indexes must be integers in [0, nsamples-1].

  Input

  > - file - [string] test indexes file
  > - nsamples - [integer] number of samples

  Output

  > - idx - list of tuples: ([training indexes],[test indexes])