original_docstring: Normalize the array Y using statistics or its range.
      In case Y is effectively a 2d-array normalize by column
  
      :param Y: array that you want to normalize.
      :param normalization_type: String specifying the kind of normalization
      to use. Options are 'stats' to use mean and standard deviation,
      or 'maxmin' to use the range of function values.
      :param target
      
      :return Y_normalized: The normalized vector.
      
docstring: Normalize the array Y using statistics or its range.
  In case Y is effectively a 2d-array normalize by column
  
  :param Y: array that you want to normalize.
  :param normalization_type: String specifying the kind of normalization
  to use. Options are 'stats' to use mean and standard deviation,
  or 'maxmin' to use the range of function values.
  :param target
  
  :return Y_normalized: The normalized vector.
docstring_tokens: Normalize the array Y using statistics or its range . In case Y is effectively a 2d - array normalize by column : param Y : array that you want to normalize . : param normalization_type : String specifying the kind of normalization to use . Options are ' stats ' to use mean and standard deviation or ' maxmin ' to use the range of function values . : param target : return Y_normalized : The normalized vector .
code: def normalize(Y, normalization_type='stats', target = None, return_normargs=False):
      """Normalize the array Y using statistics or its range.
      In case Y is effectively a 2d-array normalize by column
  
      :param Y: array that you want to normalize.
      :param normalization_type: String specifying the kind of normalization
      to use. Options are 'stats' to use mean and standard deviation,
      or 'maxmin' to use the range of function values.
      :param target
      
      :return Y_normalized: The normalized vector.
      """
      Y = np.asarray(Y, dtype=float)
  
      #if np.max(Y.shape) != Y.size:
      #    raise NotImplementedError('Only 1-dimensional arrays are supported.')
  
      # Only normalize with non null sdev (divide by zero). For only one
      # data point both std and ptp return 0.
      if normalization_type == 'stats':
          mean = Y.mean(0)
          std = Y.std(0)
          std[std<=0] = 1.
          args = {'mean': mean, 'std':std}
          if target is not None:
              target_norm = (target - mean) / std        
          mean = np.repeat(mean[np.newaxis, :], len(Y),0)
          std = np.repeat(std[np.newaxis, :], len(Y),0)
          Y_norm = (Y - mean)/std
          
  
      elif normalization_type == 'maxmin':
          Y_min = Y.min(0)
          Y_range = np.ptp(Y, 0)
          if target is not None:
              target_norm = target - Y_min
              target_norm[Y_range > 0] = 2 * (target_norm[Y_range > 0] / Y_range[Y_range > 0] - 0.5)
          Y_min = np.repeat(Y_min[np.newaxis, :], len(Y), 0)
          Y_range= np.repeat(Y_range[np.newaxis, :], len(Y), 0)         
          Y_norm = Y - Y_min
          Y_norm[Y_range > 0] = 2 * (Y_norm[Y_range > 0] / Y_range[Y_range > 0] - 0.5)
          args = {'min': Y_range[0], 'max': Y_range[1]}
  
      else:
          raise ValueError('Unknown normalization type: {}'.format(normalization_type))
      if return_normargs:
          if target is None:
              return Y_norm, args
          else:
              assert len(target) == Y.shape[1], "target has shape {} while Y is {}".format(np.shape(target), np.shape(Y))
              return Y_norm, target_norm, args
      else:
          if target is None:
              return Y_norm
          else:
              assert len(target) == Y.shape[1], "target has shape {} while Y is {}".format(np.shape(target), np.shape(Y))
              return Y_norm, target_norm
code_tokens: def normalize ( Y , normalization_type = 'stats' , target = None , return_normargs = False ) : Y = np . asarray ( Y , dtype = float ) if normalization_type == 'stats' : mean = Y . mean ( 0 ) std = Y . std ( 0 ) std [ std <= 0 ] = 1. args = { 'mean' : mean , 'std' : std } if target is not None : target_norm = ( target - mean ) / std mean = np . repeat ( mean [ np . newaxis , : ] , len ( Y ) , 0 ) std = np . repeat ( std [ np . newaxis , : ] , len ( Y ) , 0 ) Y_norm = ( Y - mean ) / std elif normalization_type == 'maxmin' : Y_min = Y . min ( 0 ) Y_range = np . ptp ( Y , 0 ) if target is not None : target_norm = target - Y_min target_norm [ Y_range > 0 ] = 2 * ( target_norm [ Y_range > 0 ] / Y_range [ Y_range > 0 ] - 0.5 ) Y_min = np . repeat ( Y_min [ np . newaxis , : ] , len ( Y ) , 0 ) Y_range = np . repeat ( Y_range [ np . newaxis , : ] , len ( Y ) , 0 ) Y_norm = Y - Y_min Y_norm [ Y_range > 0 ] = 2 * ( Y_norm [ Y_range > 0 ] / Y_range [ Y_range > 0 ] - 0.5 ) args = { 'min' : Y_range [ 0 ] , 'max' : Y_range [ 1 ] } else : raise ValueError ( 'Unknown normalization type: {}' . format ( normalization_type ) ) if return_normargs : if target is None : return Y_norm , args else : assert len ( target ) == Y . shape [ 1 ] , "target has shape {} while Y is {}" . format ( np . shape ( target ) , np . shape ( Y ) ) return Y_norm , target_norm , args else : if target is None : return Y_norm else : assert len ( target ) == Y . shape [ 1 ] , "target has shape {} while Y is {}" . format ( np . shape ( target ) , np . shape ( Y ) ) return Y_norm , target_norm
short_docstring: Normalize the array Y using statistics or its range.
short_docstring_tokens: Normalize the array Y using statistics or its range .
comment: """Normalize the array Y using statistics or its range.
      In case Y is effectively a 2d-array normalize by column
  
      :param Y: array that you want to normalize.
      :param normalization_type: String specifying the kind of normalization
      to use. Options are 'stats' to use mean and standard deviation,
      or 'maxmin' to use the range of function values.
      :param target
      
      :return Y_normalized: The normalized vector.
      """$SEP$#if np.max(Y.shape) != Y.size:$SEP$#    raise NotImplementedError('Only 1-dimensional arrays are supported.')$SEP$# Only normalize with non null sdev (divide by zero). For only one$SEP$# data point both std and ptp return 0.