preprocessing

preprocessing pipeline

ardent.preprocessing.__init__.preprocess(data, processes)[source]

Perform each preprocessing function in processes, in the order listed, on data if it is an array, or on each element in data if it is a list of arrays.

Parameters:
  • data (np.ndarray, list) -- The array or list of arrays to be preprocessed.
  • processes (list) -- The list of strings, each corresponding to the name of a preprocessing function.
  • process_kwargs (seq, optional) -- A sequence of dictionaries containing kwargs for each element of processes. Defaults to None.
Raises:
  • TypeError -- Raised if data is a list whose elements are not all of type np.ndarray.
  • TypeError -- Raised if data is neither a np.ndarray or a list of np.ndarrays.
  • TypeError -- Raised if an element of processes is neither a single string nor an iterable.
  • ValueError -- Raised if an element of processes is an iterable but not of length 2.
  • ValueError -- Raised if an alement of processes is a 2-element iterable whose first element is not a string.
  • ValueError -- Raised if an alement of processes is a 2-element iterable whose second element is not a dictionary.
  • TypeError -- Raised if an element of processes includes a dictionary with a key that is not a string.
  • ValueError -- Raised if any element of processes is not a recognized preprocessing function.
Returns:

A copy of data after having each function in processes applied.

Return type:

np.ndarray, list

resampling

normalization

ardent.preprocessing.normalization.cast_to_typed_array(data, dtype=<class 'float'>)[source]

Returns a copy of data cast as a np.ndarray of type dtype.

Parameters:
  • data (np.ndarray) -- The array to be cast.
  • dtype (type, optional) -- The dtype to cast data to. Defaults to float. Defaults to float.
Returns:

A copy of data cast to type dtype.

Return type:

np.ndarray

ardent.preprocessing.normalization.normalize_by_MAD(data)[source]

Returns a copy of data divided by its mean absolute deviation.

Parameters:data (np.ndarray) -- The array to be normalized.
Returns:A copy of data divided by its mean absolute deviation.
Return type:np.ndarray
ardent.preprocessing.normalization.center_to_mean(data)[source]

Returns a copy of data subtracted by its mean.

Parameters:data (np.ndarray) -- The array to be subtracted from.
Returns:A copy of data subtracted by its mean.
Return type:np.ndarray
ardent.preprocessing.normalization.pad(data, pad_width=10, mode='constant', constant_values=None)[source]

Returns a padded copy of data.

Parameters:
  • data (np.ndarray) -- The array to be padded.
  • pad_width (int, optional) -- The amount by which to pad. Defaults to 10.
  • mode (str, optional) -- The padding mode used in np.pad. Defaults to 'constant'.
  • constant_values (float, optional) -- The values to use in padding if mode='constant' If None, this is set to np.quantile(data, 10**-data.ndim). Defaults to None.
Returns:

The padded copy of data.

Return type:

np.ndarray