wavedec

hana_ml.algorithms.pal.tsa.wavelet.wavedec(data, wavelet, key=None, col=None, boundary=None, level=None, compression=None, method=None, threshold=None, level_thresholds=None)

Python wrapper for PAL multi-level discrete wavelet transform.

Parameters:
dataDataFrame

Time-series data to apply discrete wavelet transform to. It should be comprised of the following two columns:

  • 1st column : Time-stamp, type INTEGER. The stamp values do not need to be in order.

  • 2nd column : Signal values, type DOUBLE or DECIMAL(p,s), must be evenly-spaced in time.

waveletstr

Specifies the wavelet filter used for discrete wavelet transform. Valid options include:

  • Daubechies family : 'db1' ~ 'db20'

  • Biorthogonal family: 'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6', 'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9', 'bior4.4', 'bior5.5', 'bior6.8'

  • Reverse Biorthogonal family : 'rbio1.1', 'rbio1.3', 'rbio1.5', 'rbio2.2', 'rbio2.4', 'rbio2.6', 'rbio2.8', 'rbio3.1', 'rbio3.3', 'rbio3.5', 'rbio3.7', 'rbio3.9', 'rbio4.4', 'rbio5.5', 'rbio6.8'

  • Coifman family: 'coif1' ~ 'coif5'

  • Symmetric family: 'sym2' ~ 'sym20'

keystr

Specifies the time-stamp column in data.

The column should be of type INTEGER. The values do not need to be in order, but must be equal-spaced.

colstr, optional

Specifies the signal values for wavelet transformation, should be of type DOUBLE or DECIMAL(p,s).

If not specified, it defaults to the first non-key column of data.

boundarystr, optional

Specifies the padding method for boundary values. Valid options include:

  • 'zero' : Zero padding

  • 'symmetric' : Symmetric padding

  • 'periodic' : Periodic padding

  • 'reflect' : Reflect padding

  • 'smooth' : Smooth padding

  • 'constant' : Constant padding

Defaults to 'zero'.

levelint, optional

Specifies the decompose level for wavelet transform.

Defaults to 1.

compressionbool, optional

Specifies whether or not to discard zero values in wavelet coefficients.

Defaults to False.

method{'no', 'soft', 'hard'}, optional

Specifies the thresholding method applied to wavelet coefficients.

  • 'no' : No thresholding

  • 'soft' : Soft-thresholding

  • 'hard' : Hard-thresholding

Defaults to 'no'.

thresholdfloat, optional

Specifies the uniform thresholding value for soft/hard-thresholding.

Valid only when method is set as 'soft' or 'hard'.

Defaults to 1e-9.

level_thresholdsListOfTuples, optional

Specifies level-wise thresholding values via a list of tuples, with the 1st element of each tuple being the level, and 2nd element being the respective thresholding value. For example, [(1, 1e-2), (2, 1e-3)] means using threshold 1e-2 for level 1 wavelet coefficients for thresholding, and 1e-3 for level-2 wavelet coefficients for thresholding.

If both threshold and level_thresholds are specified, level_thresholds takes precedence.

Returns:
A DWT object

The returned DWT object contains all related information for the wavelet transformation, including wavelet filter, boundary extension type, decomposition level, etc. In particular, it contains the wavelet transformation of data in its coeff_ attribute.

For more details, see the Attributes section of DWT.

Examples

Input time-series data for discrete wavelet transformation:

>>> data.collect()
    ID    VAL
0    1  266.0
1    2  145.9
2    3  181.3
3    4  119.3
4    5  180.3
5    6  168.5
6    7  231.8
7    8  224.5
8    9  192.8
9   10  122.9
10  11  336.5
11  12  185.9
12  13  194.3
13  14  149.5

2-level decomposition of the input data using 'db2' filter, symmetric padding method:

>>> dwt = wavedec(data=data, wavelet='db2', boundary='symmetric', level=2)

dwt is a DWT object containing the decomposition result in its attribute coeff_:

>>> dwt.coeff_.collect()
    LEVEL  ID  COEFFICIENTS
0       0   0    451.442328
1       0   1    405.506091
2       0   2    350.691644
3       0   3    412.118406
4       0   4    362.046517
5       1   0     73.545930
6       1   1     26.917407
7       1   2     19.242329
8       1   3     24.378527
9       1   4     21.606776
10      1   5    139.207493
11      1   6      5.117513
12      1   7    -27.434285
13      2   0     35.520329
14      2   1    -53.885358
15      2   2     71.258862
16      2   3     78.767514
17      2   4    -70.401833