nirs4all.operators.augmentation.splines module
- class nirs4all.operators.augmentation.splines.Spline_Curve_Simplification(apply_on='samples', random_state=None, *, copy=True, spline_points=None, uniform=False)[source]
Bases:
AugmenterClass to simplify a 1D signal using B-spline interpolation along the curve.
Optimized implementation with pre-allocated output arrays.
- Parameters:
X (ndarray) – Input data.
apply_on (str, optional) – Apply augmentation on “samples” or “global” (default: “samples”).
spline_points (int, optional) – Number of spline points for simplification. Default is None: the length of the sample / 4.
uniform (bool, optional) – If True, the spline points are uniformly spaced. Default is False.
- augment(X, apply_on='samples')[source]
Select regularly spaced points on the x-axis and adjust a spline.
Optimized with pre-allocated output array.
- Parameters:
X (ndarray) – Input data.
apply_on (str, optional) – Apply augmentation on “samples” or “features” (default: “samples”).
- Returns:
Augmented data.
- Return type:
ndarray
- class nirs4all.operators.augmentation.splines.Spline_Smoothing(apply_on='samples', random_state=None, *, copy=True)[source]
Bases:
AugmenterClass to apply a smoothing spline to a 1D signal.
- Parameters:
X (ndarray) – Input data.
apply_on (str, optional) – Apply augmentation on “samples” or “global” (default: “samples”).
- augment(X, apply_on='samples')[source]
Apply a smoothing spline to the data.
Optimized implementation with pre-allocated output array.
- Parameters:
X (ndarray) – Input data.
apply_on (str, optional) – Apply augmentation on “samples” or “global” (default: “samples”).
- Returns:
Augmented data.
- Return type:
ndarray
- class nirs4all.operators.augmentation.splines.Spline_X_Perturbations(apply_on='samples', random_state=None, *, copy=True, spline_degree=3, perturbation_density=0.05, perturbation_range=(-10, 10))[source]
Bases:
AugmenterClass to apply a perturbation to a 1D signal using B-spline interpolation.
Optimized implementation with pre-generated random parameters.
- Parameters:
X (ndarray) – Input data.
apply_on (str, optional) – Apply augmentation on “samples” or “global” (default: “samples”).
spline_degree (int, optional) – Degree of the spline. Default is 3 (cubic).
perturbation_density (float, optional) – Density of perturbation points relative to data size. Default is 0.05.
perturbation_range (tuple, optional) – Range of perturbation values (min, max). Default is (-10, 10).
- augment(X, apply_on='samples')[source]
Augment the data with a perturbation using B-spline interpolation.
Optimized with pre-allocated arrays and batch random generation.
- Parameters:
X (ndarray) – Input data to be augmented.
apply_on (str, optional) – Apply augmentation on “samples” or “global” data. Default is “samples”.
- Returns:
Augmented data.
- Return type:
ndarray
- class nirs4all.operators.augmentation.splines.Spline_X_Simplification(apply_on='samples', random_state=None, *, copy=True, spline_points=None, uniform=False)[source]
Bases:
AugmenterClass to simplify a 1D signal using B-spline interpolation along the x-axis.
Optimized implementation with pre-generated random parameters.
- Parameters:
X (ndarray) – Input data.
apply_on (str, optional) – Apply augmentation on “samples” or “global” (default: “samples”).
spline_points (int, optional) – Number of spline points for simplification. Default is None: the length of the sample / 4.
uniform (bool, optional) – If True, the spline points are uniformly spaced. Default is False.
- augment(X, apply_on='samples')[source]
Select randomly spaced points along the x-axis and adjust a spline.
Optimized with pre-allocated arrays and batch random generation.
- Parameters:
X (ndarray) – Input data.
apply_on (str, optional) – Apply augmentation on “samples” or “global” (default: “samples”).
- Returns:
Augmented data.
- Return type:
ndarray
- class nirs4all.operators.augmentation.splines.Spline_Y_Perturbations(apply_on='samples', random_state=None, *, copy=True, spline_points=None, perturbation_intensity=0.005)[source]
Bases:
AugmenterAugment the data with a perturbation on the y-axis using B-spline interpolation.
Optimized implementation with pre-generated random parameters.
- Parameters:
X (ndarray) – Input data.
apply_on (str, optional) – Apply augmentation on “samples” or “global” (default: “samples”).
spline_points (int, optional) – Number of spline points. Default is None (uses sample length / 2).
perturbation_intensity (float, optional) – Intensity of perturbation relative to max value. Default is 0.005.
- augment(X, apply_on='samples')[source]
Augment the data with a perturbation on the y-axis using B-spline interpolation.
Optimized with pre-allocated arrays and batch random generation.
- Parameters:
X (ndarray) – Input data to be augmented.
apply_on (str, optional) – Apply augmentation on “samples” or “global” data. Default is “samples”.
- Returns:
Augmented data.
- Return type:
ndarray
- nirs4all.operators.augmentation.splines.X_length(x, y)[source]
Compute the total length, segment lengths, and cumulative segment lengths of a curve.
Vectorized implementation without np.vectorize.
- Parameters:
x (ndarray) – Array of x-coordinates of the curve.
y (ndarray) – Array of y-coordinates of the curve.
- Returns:
A tuple containing the total length, segment lengths, and cumulative segment lengths.
- Return type:
- nirs4all.operators.augmentation.splines.interval_selection(n_l, CumVect)[source]
Select the interval indices that bound a given value in an array.
- nirs4all.operators.augmentation.splines.segment_length(x1, y1, x2, y2)[source]
Compute the length of a line segment given its coordinates.
- nirs4all.operators.augmentation.splines.segment_pt_coord(x1, y1, x2, y2, fracL, L)[source]
Compute the coordinates of a point on a line segment given the fraction of its length.
- Parameters:
x1 (float) – x-coordinate of the first point of the line segment.
y1 (float) – y-coordinate of the first point of the line segment.
x2 (float) – x-coordinate of the second point of the line segment.
y2 (float) – y-coordinate of the second point of the line segment.
fracL (float) – Fraction of the length of the line segment.
L (float) – Length of the line segment.
- Returns:
A tuple containing the x and y coordinates of the point on the line segment.
- Return type: