romspline/cross_validation.py
def MonteCarloKfold(self, x, y, n, K=10, parallel=True, random=True, verbose=False):
    """Perform a number n of K-fold cross-validations
    
    Input
    -----
      x        -- samples
      y        -- data to be downsampled
      n        -- number of times to repeat K-fold cross-validation
                  with a random distribution of the data into the 
                  K partitions
      K        -- number of partitions
                  (default 10)
      parallel -- parallelize the computation over each partition?
                  (default True)
      random   -- fill the partitions randomly from the data?
                  (default True)
      verbose  -- print progress to screen?
                  (default False)
    
    Attributes
    ----------
      all_args   -- array of data array indexes of validation errors on each
                   validation set
      all_errors -- array of validation errors on each realized validation set
    
    Comments
    --------
    The default option for `K` is 10 so that a random 10% subset of the 
    data is used to validate the trial reduced-order splines.
    
    If `random` option is False then the partitions are filled with the
    data in sequential order. This is not a good idea for trying to 
    assess interpolation errors because interpolating over large regions
    of data will likely incur large errors. This option may be removed in 
    future romSpline releases.
    """
    
    # Allocate memory
    self.all_args = np.zeros((n,K), dtype='int')
    self.all_errors = np.zeros((n,K), dtype='double')
    self.all_args_ge_tol = []
    self.all_errors_ge_tol = []
    for nn in range(n):
      
      if verbose and not (nn+1)%10:
        print("Trials completed:", nn+1)
      
      self.Kfold(x, y, K=K, parallel=parallel, random=random)
      self.all_args[nn] = self.args
      self.all_errors[nn] = self.errors
      
      self.all_args_ge_tol.append( list(self.args[self.errors >= self._tol]) )
      self.all_errors_ge_tol.append( list(self.errors[self.errors >= self._tol]) )
Perform a number n of K-fold cross-validations
    
    Input
    -----
      x        -- samples
      y        -- data to be downsampled
      n        -- number of times to repeat K-fold cross-validation
                  with a random distribution of the data into the 
                  K partitions
      K        -- number of partitions
                  (default 10)
      parallel -- parallelize the computation over each partition?
                  (default True)
      random   -- fill the partitions randomly from the data?
                  (default True)
      verbose  -- print progress to screen?
                  (default False)
    
    Attributes
    ----------
      all_args   -- array of data array indexes of validation errors on each
                   validation set
      all_errors -- array of validation errors on each realized validation set
    
    Comments
    --------
    The default option for `K` is 10 so that a random 10% subset of the 
    data is used to validate the trial reduced-order splines.
    
    If `random` option is False then the partitions are filled with the
    data in sequential order. This is not a good idea for trying to 
    assess interpolation errors because interpolating over large regions
    of data will likely incur large errors. This option may be removed in 
    future romSpline releases.
    
Perform a number n of K-fold cross-validations
Input



Attributes

all_args   -- array of data array indexes of validation errors on each
validation set
all_errors -- array of validation errors on each realized validation set

Comments

The default option for `K` is 10 so that a random 10% subset of the
data is used to validate the trial reduced-order splines.

If `random` option is False then the partitions are filled with the
data in sequential order. This is not a good idea for trying to
assess interpolation errors because interpolating over large regions
of data will likely incur large errors. This option may be removed in
future romSpline releases.
Perform a number n of K - fold cross - validations Input Attributes all_args -- array of data array indexes of validation errors on each validation set all_errors -- array of validation errors on each realized validation set Comments The default option for ` K ` is 10 so that a random 10% subset of the data is used to validate the trial reduced - order splines . If ` random ` option is False then the partitions are filled with the data in sequential order . This is not a good idea for trying to assess interpolation errors because interpolating over large regions of data will likely incur large errors . This option may be removed in future romSpline releases .
def MonteCarloKfold(self, x, y, n, K=10, parallel=True, random=True, verbose=False):
    self.all_args = np.zeros((n,K), dtype='int')
    self.all_errors = np.zeros((n,K), dtype='double')
    self.all_args_ge_tol = []
    self.all_errors_ge_tol = []
    for nn in range(n):
      if verbose and not (nn+1)%10:
        print("Trials completed:", nn+1)
      self.Kfold(x, y, K=K, parallel=parallel, random=random)
      self.all_args[nn] = self.args
      self.all_errors[nn] = self.errors
      self.all_args_ge_tol.append( list(self.args[self.errors >= self._tol]) )
      self.all_errors_ge_tol.append( list(self.errors[self.errors >= self._tol]) )
def MonteCarloKfold ( self , x , y , n , K = 10 , parallel = True , random = True , verbose = False ) : self . all_args = np . zeros ( ( n , K ) , dtype = 'int' ) self . all_errors = np . zeros ( ( n , K ) , dtype = 'double' ) self . all_args_ge_tol = [ ] self . all_errors_ge_tol = [ ] for nn in range ( n ) : if verbose and not ( nn + 1 ) % 10 : print ( "Trials completed:" , nn + 1 ) self . Kfold ( x , y , K = K , parallel = parallel , random = random ) self . all_args [ nn ] = self . args self . all_errors [ nn ] = self . errors self . all_args_ge_tol . append ( list ( self . args [ self . errors >= self . _tol ] ) ) self . all_errors_ge_tol . append ( list ( self . errors [ self . errors >= self . _tol ] ) )
Perform a number n of K-fold cross-validations
Input
Perform a number n of K - fold cross - validations Input
"""Perform a number n of K-fold cross-validations
    
    Input
    -----
      x        -- samples
      y        -- data to be downsampled
      n        -- number of times to repeat K-fold cross-validation
                  with a random distribution of the data into the 
                  K partitions
      K        -- number of partitions
                  (default 10)
      parallel -- parallelize the computation over each partition?
                  (default True)
      random   -- fill the partitions randomly from the data?
                  (default True)
      verbose  -- print progress to screen?
                  (default False)
    
    Attributes
    ----------
      all_args   -- array of data array indexes of validation errors on each
                   validation set
      all_errors -- array of validation errors on each realized validation set
    
    Comments
    --------
    The default option for `K` is 10 so that a random 10% subset of the 
    data is used to validate the trial reduced-order splines.
    
    If `random` option is False then the partitions are filled with the
    data in sequential order. This is not a good idea for trying to 
    assess interpolation errors because interpolating over large regions
    of data will likely incur large errors. This option may be removed in 
    future romSpline releases.
    """ # Allocate memory
self
x
y
n
K
parallel
random
verbose