Skip to content

Inter-Quartile Range Transform

The inter-quartile range transform computes the inter-quartile range of the data in a sliding window. The inter-quartile range is the difference between the \(75^{th}\) and \(25^{th}\) percentiles of the data and can be defined as:

\[ \text{IQR} = \text{Q3} - \text{Q1} \]

where \(\text{Q1}\) and \(\text{Q3}\) are the \(25^{th}\) and \(75^{th}\) percentiles of the data, respectively.

Bases: Transform

Compute the inter-quartile range of the values.

__call__(signal_window, method='linear', where=lambda : not np.isnan(x))

Compute the inter-quartile range of the values in x.

Parameters:

Name Type Description Default
signal_window ndarray

The array to compute the IQR of.

required
method str

The method to use when computing the quantiles. Default is 'linear'. See numpy.quantile for more information.

'linear'
where Callable[[Union[int, float, int_, float_]], Union[bool, bool_]]

A function that takes a value and returns True or False. Default is lambda x: not np.isnan(x) i.e. a measurement is valid if it is not a NaN value.

lambda : not numpy.isnan(x)

Returns:

Type Description
Union[float_, int_]

A scalar value representing the IQR of the signal.

Examples

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.IQRTransform()

# Get featurizer
featurizer = window.use(tf)

# Get features
features = featurizer(x)

# Print features
print(window)
print(tf)
print(features)

If you enjoy using AutonFeat, please consider starring the repository ⭐️.