Class FeatureNoise<T>
- Namespace
- AiDotNet.Augmentation.Tabular
- Assembly
- AiDotNet.dll
Adds Gaussian noise to numerical features in tabular data.
public class FeatureNoise<T> : TabularAugmenterBase<T>, IAugmentation<T, Matrix<T>>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationBase<T, Matrix<T>>FeatureNoise<T>
- Implements
-
IAugmentation<T, Matrix<T>>
- Inherited Members
Remarks
For Beginners: This augmentation adds small random variations to your data, similar to measurement noise in real-world data. This helps models become robust to small fluctuations and prevents overfitting to exact values.
When to use:
- Numerical features that have natural variation
- Small datasets where regularization is needed
- When you want to simulate measurement uncertainty
When NOT to use:
- Categorical features (use other augmentations)
- Features with strict constraints (e.g., binary flags)
Constructors
FeatureNoise(double, double, int[]?)
Creates a new feature noise augmentation.
public FeatureNoise(double noiseStdDev = 0.01, double probability = 0.5, int[]? featureIndices = null)
Parameters
noiseStdDevdoubleStandard deviation of Gaussian noise (default: 0.01).
probabilitydoubleProbability of applying this augmentation (default: 0.5).
featureIndicesint[]Optional array of feature indices to apply noise to.
Properties
FeatureIndices
Gets or sets the indices of features to apply noise to.
public int[]? FeatureIndices { get; set; }
Property Value
- int[]
Remarks
If null, applies to all features.
NoiseStdDev
Gets the standard deviation of the noise.
public double NoiseStdDev { get; }
Property Value
Remarks
Default: 0.01 (1% of unit variance)
Higher values add more noise. Typical range: 0.001 to 0.1
Methods
ApplyAugmentation(Matrix<T>, AugmentationContext<T>)
Implement this method to perform the actual augmentation.
protected override Matrix<T> ApplyAugmentation(Matrix<T> data, AugmentationContext<T> context)
Parameters
dataMatrix<T>The input data.
contextAugmentationContext<T>The augmentation context.
Returns
- Matrix<T>
The augmented data.
GetParameters()
Gets the parameters of this augmentation.
public override IDictionary<string, object> GetParameters()
Returns
- IDictionary<string, object>
A dictionary of parameter names to values.