Range Function¶
The range function computes the range of the data in the sliding window. When paired with the SlidingWindow
abstraction, one can compute the range over a sliding window across a time series. The range is computed as the difference between the maximum and minimum values in the window and can be defined as:
\[ \text{range} = \max(x) - \min(x) \]
where \(x\) is the data in the sliding window.
Compute the range of the values in x
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | ndarray | The array to compute the range of. | required |
where | Callable[[Union[int, float, int_, float_]], Union[bool, bool_]] | A function that takes a value and returns | lambda : not numpy.isnan(x) |
Returns:
Type | Description |
---|---|
Union[float, float_] | The range of the values in |
Examples¶
import numpy as np
import autonfeat as aft
import autonfeat.functional as F
# Random data
n_samples = 100
x = np.random.rand(n_samples)
# Create sliding window
ws = 10
ss = 10
window = aft.SlidingWindow(window_size=ws, step_size=ss)
# Get featurizer
featurizer = window.use(F.range_tf)
# Get features
features = featurizer(x)
# Print features
print(features)
If you enjoy using AutonFeat
, please consider starring the repository ⭐️.