extractors.symbolic_dynamic_filtering

Module: extractors.symbolic_dynamic_filtering

This program implements the symbolic dynamic filtering (SDF) algorithm as a time series feature extraction method, presented in the following paper:

Bahrampour, Soheil, Asok Ray, Soumalya Sarkar, Thyagaraju Damarla, and Nasser M. Nasrabadi. “Performance comparison of feature extraction algorithms for target detection and classification.” Pattern Recognition Letters 34, no. 16 (2013): 2126-2134.

Written by Soheil Bahrampour, August 2012 Rewritten in Python by Arno Klein, November 2015

Authors:

Functions

mhealthx.extractors.symbolic_dynamic_filtering.analyze_symbol_sequence(symbols, number_of_states, morph_matrix_flag)

Estimate the state transition probability (“morph”) matrix of the probabilistic finite state automata, and its eigenvector corresponding to eigenvalue 1 by counting.

NOTE: Currently the number of states is set to the number of symbols.

symbol_sequence : numpy array number_of_states : integer morph_matrix_flag : Boolean

morph_matrix : numpy array pvec : numpy array

>>> # Example checked against original Matlab code:
>>> import numpy as np
>>> from mhealthx.extractors.symbolic_dynamic_filtering import analyze_symbol_sequence, generate_symbol_sequence, max_entropy_partition
>>> data = np.array([0.82487374,  0.21834812,  0.60166418,  0.76465689, 0.44819955,  0.72335342,  0.8710113,  0.73258881, 0.97047932,  0.5975058,  0.02474567,  0.38093561]) #np.random.random((3,4))
>>> number_of_symbols = 4
>>> partition = max_entropy_partition(data, number_of_symbols)
>>> symbols = generate_symbol_sequence(data, partition)
>>> number_of_states = number_of_symbols
>>> morph_matrix_flag = True
>>> morph_matrix, pvec = analyze_symbol_sequence(symbols, number_of_states, morph_matrix_flag)
array([[ 0.        ,  0.5       ,  0.        ,  0.5       ],
       [ 0.33333333,  0.        ,  0.        ,  0.66666667],
       [ 0.33333333,  0.33333333,  0.        ,  0.33333333],
       [ 0.        ,  0.        ,  1.        ,  0.        ]])
array([ 0.18181818,  0.18181818,  0.27272727,  0.36363636])
mhealthx.extractors.symbolic_dynamic_filtering.generate_symbol_sequence(data, partition)

Generate symbol sequence of a given time series using given partition.

data : numpy array partition : numpy array

symbols : numpy array

>>> # Example checked against original Matlab code:
>>> import numpy as np
>>> from mhealthx.extractors.symbolic_dynamic_filtering import generate_symbol_sequence, max_entropy_partition
>>> data = np.array([0.82487374,  0.21834812,  0.60166418,  0.76465689, 0.44819955,  0.72335342,  0.8710113,  0.73258881, 0.97047932,  0.5975058,  0.02474567,  0.38093561]) #np.random.random((3,4))
>>> number_of_symbols = 4
>>> partition = max_entropy_partition(data, number_of_symbols)
>>> symbols = generate_symbol_sequence(data, partition)
array([ 4.,  1.,  3.,  4.,  2.,  3.,  4.,  3.,  4.,  2.,  1.,  2.])
mhealthx.extractors.symbolic_dynamic_filtering.max_entropy_partition(data, number_of_symbols)

Perform maximum entropy partitioning on given data.

data : numpy array number_of_symbols : integer

number of symbols for symbolic dynamic filtering method

partition : numpy array

>>> # Example checked against original Matlab code:
>>> import numpy as np
>>> from mhealthx.extractors.symbolic_dynamic_filtering import max_entropy_partition
>>> data = np.array([0.82487374,  0.21834812,  0.60166418,  0.76465689, 0.44819955,  0.72335342,  0.8710113,  0.73258881, 0.97047932,  0.5975058,  0.02474567,  0.38093561]) #np.random.random((3,4))
>>> number_of_symbols = 4
>>> partition = max_entropy_partition(data, number_of_symbols)
array([ 0.38093561,  0.60166418,  0.76465689])
mhealthx.extractors.symbolic_dynamic_filtering.sdf_features(data, number_of_symbols, pi_matrix_flag=False)

Extract symbolic dynamic filtering features from time series data.

NOTE: Currently the number of states is set to the number of symbols.

data : numpy array number_of_symbols : integer

number of symbols for symbolic dynamic filtering method
pi_matrix_flag : Boolean
feature as vectorized morph matrix (default: False)?

feature : numpy array

>>> # Example checked against original Matlab code:
>>> import numpy as np
>>> from mhealthx.extractors.symbolic_dynamic_filtering import sdf_features
>>> data = np.array([0.82487374,  0.21834812,  0.60166418,  0.76465689, 0.44819955,  0.72335342,  0.8710113,  0.73258881, 0.97047932,  0.5975058,  0.02474567,  0.38093561]) #np.random.random((3,4))
>>> number_of_symbols = 4
>>> pi_matrix_flag = False
>>> feature = sdf_features(data, number_of_symbols, pi_matrix_flag)
array([ 0.18181818,  0.18181818,  0.27272727,  0.36363636])