Module augmenters

Source
Expand description

Module for the Augmenter trait and all augmenters this crate implements.

Every augmenter implements the Augmenter trait which enables a unified interface with the methods augment_batch and augment_one

§Examples

Every augmenter can be used analogously to these examples

use fraug::augmenters::{Augmenter, Rotation};
 
let series = vec![1.0; 100];

let augmenter = Rotation::new(0.5);
let series = augmenter.augment_one(&series);

assert_eq!(series, vec![0.0; 100]);
use fraug::Dataset;
use fraug::augmenters::*;

let series = vec![1.0; 100];
let mut set = Dataset {
   features: vec![series],
   labels: vec![String::from("1")],
};
 
let mut jittering = Jittering::new(0.2);
jittering.set_probability(0.5); // Only do jittering for half of the series in the batch
 
let pipeline = AugmentationPipeline::new() 
               + Repeat::new(5) 
               + Crop::new(20)
               + jittering;

pipeline.augment_batch(&mut set, true, false);

assert_eq!(set.features.len(), 5);
assert_eq!(set.features[3].len(), 20);

Structs§

AddNoise
Augmenter that allows different types of noise injection
AmplitudePhasePerturbation
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.
AugmentationPipeline
A pipeline of augmenters
Convolve
Usage of this augmenter is to convolve time series data with a kernel
Crop
Augmenter that crops each series into a random continuous slice of specified size
Drift
Drifts the value of a time series by a random value at each point in the series.
Drop
Augmenter that drops data points in series
FrequencyMask
This augmenter applies a frequency-domain mask to each time series, zeroing out a contiguous block of frequency bins.
Jittering
Augmenter that adds white gaussian noise of the specified standard deviation and a mean of 0
Permutate
Permutate time series
Pool
Reduces the temporal resolution without changing the length by pooling multiple samples together
Quantize
Quantize time series to a level set
RandomTimeWarpAugmenter
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.
Repeat
Augmenter that repeats all data rows n times
Resize
Changes temporal resolution of time series by changing the length
Reverse
Reverses time series
Rotation
Augmenter that rotates the data 180 degrees around anchor
Scaling
Augmenter that scales a time series with a random scalar within the range specified by min_factor (inclusive) and max_factor (inclusive)

Enums§

ConvolveWindow
Enum to specify the kernel window for the Convolve augmenter
NoiseType
Enum to specify the noise type for the AddNoise augmenter
PoolingMethod
Enum to specify the pooling function for the Pool augmenter

Traits§

Augmenter
Trait for all augmenters, allows for augmentation of one time series or a batch