Quantile Transform¶
The quantile transform computes the q-th quantile of the data in the sliding window. The quantile is computed using the numpy.quantile function. The transform can be combined with the SlidingWindow
to compute the quantile of the data in a sliding window. We can use this transform to compute the median of the data in a sliding window by setting q=0.5
.
Bases: Transform
Compute the q-th quantile of the values.
__call__(signal_window, q, method='linear', where=lambda : not np.isnan(x))
¶
Compute the q-th quantile of the values in x
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signal_window | ndarray | The array to compute the q-th quantile of. | required |
q | Union[float, float_] | The quantile to compute. | required |
method | str | The method to use when computing the quantile. Default is 'linear'. See | 'linear' |
where | Callable[[Union[int, float, int_, float_]], Union[bool, bool_]] |
| lambda : not numpy.isnan(x) |
Returns:
Type | Description |
---|---|
Union[float_, int_] | A scalar value representing the q-th quantile of the signal. |
Examples¶
25th percentile¶
import numpy as np
import autonfeat as aft
# 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)
# Create transform
tf = aft.QuantileTransform()
# Get featurizer
featurizer = window.use(tf)
# Get features
features = featurizer(x, q=0.25)
# Print features
print(window)
print(tf)
print(features)
Median¶
import numpy as np
import autonfeat as aft
# 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)
# Create transform
tf = aft.QuantileTransform()
# Get featurizer
featurizer = window.use(tf)
# Get features
features = featurizer(x, q=0.5)
# Print features
print(window)
print(tf)
print(features)
If you enjoy using AutonFeat
, please consider starring the repository ⭐️.