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
- Amplitude
Phase Perturbation - 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_domainis 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 bymagnitude_stdandphase_std, respectively. - Augmentation
Pipeline - 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
- Frequency
Mask - 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
- Random
Time Warp Augmenter - Augmenter that applies random time warping to the dataset
This augmenter randomly selects a window of the time series, specified by the
window_sizeargument and applies a speed change to it. The speed change is defined by thespeed_ratio_rangeargument, 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
ntimes - 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) andmax_factor(inclusive)
Enums§
- Convolve
Window - Enum to specify the kernel window for the
Convolveaugmenter - Noise
Type - Enum to specify the noise type for the AddNoise augmenter
- Pooling
Method - Enum to specify the pooling function for the
Poolaugmenter
Traits§
- Augmenter
- Trait for all augmenters, allows for augmentation of one time series or a batch