Augmenters
- class ratspy.Dataset(features, labels)
Holds multiple univariate time series with their labels
Passed to the augment_batch function from augmenters
- Attributes:
- features
- labels
- class ratspy.AddNoise(noise_type, *, bounds=None, mean=None, std_dev=None)
Augmenter that allows different types of noise injection
Noise types:
Uniform: Adds uniform noise within the given bounds given through the parameter bounds
Gaussian: Adds gaussian noise with the specified mean and standard deviation according to the corresponding parameters
Spike: Adds a spike in the series with a random magnitude (in the range specified by bounds of the standard deviation of the original time series
Slope: Adds a linear slope trend to the series with a random slope in the range specified by bounds
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.AmplitudePhasePerturbation(magnitude_std, phase_std, is_time_domain)
This augmenter perturbs the frequency representation of each time series by adding Gaussian noise to the magnitude and phase of each frequency bin.
If is_time_domain is true, the input is first transformed to the frequency domain using FFT, the perturbation is applied, and then the result is transformed back to the time domain using IFFT.
The standard deviations of the noise for magnitude and phase are controlled by magnitude_std and phase_std, respectively.
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.AugmentationPipeline
A pipeline of augmenters
Executes many augmenters at once. Append augmenters to the pipeline by adding them to the pipeline:
``` import ratspy as rp
pipeline = rp.AugmentationPipeline() + rp.Repeat(5) + rp.Crop(20) ```
Methods
augment_batch(dataset, *, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Convolve(window, size)
Usage of this augmenter is to convolve time series data with a kernel
The kernel can be flat or Gaussian, and the size of the kernel are the parameters
The convolve operation is applied to each time series in the dataset, and smoothening is achieved by averaging the values in the kernel window over the time series data.
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Crop(size)
Augmenter that crops each series into a random continuous slice of specified size
Also known as window slicing
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Drift(max_drift, n_drift_points)
Drifts the value of a time series by a random value at each point in the series.
The drift is linear between the points, bounded by max_drift.
The number of drift points is specified by n_drift_points.
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Drop(percentage, *, default=None)
Augmenter that drops data points in series
Drops percentage % of data points and replaces them with default
When omitted default = 0
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.FrequencyMask(mask_width, is_time_domain)
This augmenter applies a frequency-domain mask to each time series, zeroing out a contiguous block of frequency bins.
If is_time_domain is true, the input is first transformed to the frequency domain using FFT, the mask is applied, and then the result is transformed back to the time domain using IFFT.
The width of the mask is controlled by mask_width, and the masked region is chosen randomly for each sample.
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Jittering(standard_deviation)
Augmenter that adds white gaussian noise of the specified standard deviation and a mean of 0
A special case of the AddNoise augmenter
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Permutate(window_size, segment_size)
Permutate time series
First, slices each series into segments and then rearranges them randomly
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Pool(kind, size)
Reduces the temporal resolution without changing the length by pooling multiple samples together
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Quantize(levels)
Quantize time series to a level set
The level set is constructed by uniformly discretizing the range of all values in the series
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Repeat(times)
Augmenter that repeats all data rows n times
Resource intensive because the data needs to be copied n times
Only works with augment_batch because the data needs to be cloned
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Resize(size)
Changes temporal resolution of time series by changing the length
Does not interpolate values!
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Reverse
Reverses time series
The augmenter turns [1, 2, 3] to [3, 2, 1]
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Rotation(anchor)
Augmenter that rotates the data 180 degrees around anchor
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.Scaling(min, max)
Augmenter that scales a time series with a random scalar within the range specified by min_factor (inclusive) and max_factor (inclusive)
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series
- class ratspy.RandomTimeWarpAugmenter(window_size, speed_ratio_range)
Augmenter that applies random time warping to the dataset This augmenter randomly selects a window of the time series, specified by the window_size argument and applies a speed change to it. The speed change is defined by the speed_ratio_range argument, which specifies the minimum and maximum speed ratio. The speed ratio is a multiplier that affects how fast or slow the selected window is stretched or compressed. If the window size is 0 or larger than the time series length, the entire series is warped.
- Attributes:
- name
- probability
Methods
augment_batch(dataset, parallel)Augment a whole batch
augment_one(x)Augment one time series