Delta Min Preprocessor Transform¶
The Delta Min Preprocessor Transform shifts the input signal by the max of the signal. The is defined as:
For shifting signals by a custom \(\delta\), see the Delta Transform Preprocessor
. For more on how we compute the min of a signal, check out min
function.
Bases: Preprocess
Preprocess the signal by shifting the signal up by the minimum value.
__call__(signal, where=lambda : not np.isnan(x), initial=np.inf)
¶
Compute the difference between the values in signal
and min
where where
is True
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signal | ndarray | The array to compute the delta with. | required |
where | Callable[[Union[int, float, int_, float_]], Union[bool, bool_]] | A function that takes a value and returns | lambda : not numpy.isnan(x) |
initial | Union[int, float, int_, float_] | The initial value for the minimum. Default is | inf |
Returns:
Type | Description |
---|---|
ndarray | The shifted signal. |
Examples¶
Transform Signal¶
import numpy as np
import autonfeat as aft
# Create a random signal
time = np.linspace(0, 10, 1000)
frequency = 500 # Frequency of the signal in Hz
signal = np.sin(np.exp(np.sin(2 * np.pi * frequency * time)))
# Create Preprocessor
preprocessor = aft.preprocess.DeltaMinPreprocessor()
# Shift the signal by the minimum value
shifted_signal = preprocessor(signal)
Visualize Transform¶
import matplotlib.pyplot as plt
# Plot the original signal and the shifted signal
fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(time, signal, label='Original Signal')
ax.plot(time, shifted_signal, label='Shifted Signal')
ax.axhline(y=0, color='red', linestyle='--', linewidth=2)
ax.set_xlabel('Time (s)')
ax.set_ylabel('Amplitude')
ax.set_title('Signal')
ax.legend()
plt.tight_layout()
plt.show()
This can be seen in the figure below.
If you enjoy using AutonFeat
, please consider starring the repository ⭐️.