ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction package
Submodules
ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.calc_features module
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.calc_features.calc_features(wind_sig, dict_features, fs, **kwargs)[source]
Extraction of time series features.
- Parameters:
wind_sig (list) – Input from which features are computed, window
dict_features (dict) – Dictionary with features
fs (float or None) – Sampling frequency
**kwargs –
- features_path (
string
) – Directory of script with personal features
- features_path (
- header_names (
list or array
) – Names of each column window
- header_names (
- Returns:
Extracted features
- Return type:
DataFrame
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.calc_features.calc_window_features(dict_features, signal_window, fs, verbose=1, single_window=False, **kwargs)[source]
This function computes features matrix for one window.
- Parameters:
dict_features (dict) – Dictionary with features
signal_window (pandas DataFrame) – Input from which features are computed, window
fs (float) – Sampling frequency
verbose (int) – Level of function communication (0 or 1 (Default))
single_window (Bool) – Boolean value for printing the progress bar for only one window feature extraction
**kwargs
below (See) –
- features_path (
string
) – Directory of script with personal features
- features_path (
- header_names (
list or array
) – Names of each column window
- header_names (
- Returns:
(columns) names of the features (data) values of each features for signal
- Return type:
pandas DataFrame
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.calc_features.dataset_features_extractor(main_directory, feat_dict, verbose=1, **kwargs)[source]
Extracts features from a dataset.
- Parameters:
main_directory (String) – Input directory
feat_dict (dict) – Dictionary with features
verbose (int) – Verbosity mode. 0 = silent, 1 = progress bar. (0 or 1 (Default))
**kwargs
below (See) –
- search_criteria (
list
) – List of file names to compute features. (Example: ‘Accelerometer.txt’) (default:
None
)
- search_criteria (
- time_unit (
float
) – Time unit (default:
1e9
)
- time_unit (
- resampling_rate (
int
) – Resampling rate (default:
100
)
- resampling_rate (
- window_size (
int
) – Window size in number of samples (default:
100
)
- window_size (
- overlap (
float
) – Overlap between 0 and 1 (default:
0
)
- overlap (
- pre_process (
function
) – Function with pre processing code
(default:
None
)
- pre_process (
- output_directory (
String
) – Output directory (default:
'output_directory', str(Path.home()) + '/tsfel_output'
)
- output_directory (
- features_path (
string
) – Directory of script with personal features
- features_path (
- header_names (
list or array
) – Names of each column window
- header_names (
- n_jobs (
int
) – The number of jobs to run in parallel.
None
means 1 unless in ajoblib.parallel_backend
context.-1
means using all processors. (default:None
in Windows and-1
for other systems)
- n_jobs (
- Returns:
csv file with the extracted features
- Return type:
file
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.calc_features.time_series_features_extractor(dict_features, signal_windows, fs=None, verbose=1, **kwargs)[source]
Extraction of time series features.
- Parameters:
dict_features (dict) – Dictionary with features
signal_windows (list) – Input from which features are computed, window
fs (int or None) – Sampling frequency
verbose (int) – Verbosity mode. 0 = silent, 1 = progress bar. (0 or 1 (Default))
**kwargs
below (See) –
- window_size (
int
) – Window size in number of samples (default:
100
)
- window_size (
- overlap (
float
) – Overlap between 0 and 1 (default:
0
)
- overlap (
- features_path (
string
) – Directory of script with personal features
- features_path (
- header_names (
list or array
) – Names of each column window
- header_names (
- n_jobs (
int
) – The number of jobs to run in parallel.
None
means 1 unless in ajoblib.parallel_backend
context.-1
means using all processors. (default:None
in Windows and-1
for other systems)
- n_jobs (
- Returns:
Extracted features
- Return type:
DataFrame
ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features module
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.abs_energy(signal)[source]
Computes the absolute energy of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which the area under the curve is computed
- Returns:
Absolute energy
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.auc(signal, fs)[source]
Computes the area under the curve of the signal computed with trapezoid rule.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which the area under the curve is computed
fs (float) – Sampling Frequency
- Returns:
The area under the curve value
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.autocorr(signal)[source]
Computes autocorrelation of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which autocorrelation is computed
- Returns:
Cross correlation of 1-dimensional sequence
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.average_power(signal, fs)[source]
Computes the average power of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Signal from which average power is computed
fs (float) – Sampling frequency
- Returns:
Average power
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.calc_centroid(signal, fs)[source]
Computes the centroid along the time axis.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which centroid is computed
fs (int) – Signal sampling frequency
- Returns:
Temporal centroid
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.calc_max(signal)[source]
Computes the maximum value of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which max is computed
- Returns:
Maximum result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.calc_mean(signal)[source]
Computes mean value of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which mean is computed.
- Returns:
Mean result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.calc_median(signal)[source]
Computes median of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which median is computed
- Returns:
Median result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.calc_min(signal)[source]
Computes the minimum value of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which min is computed
- Returns:
Minimum result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.calc_std(signal)[source]
Computes standard deviation (std) of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which std is computed
- Returns:
Standard deviation result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.calc_var(signal)[source]
Computes variance of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which var is computed
- Returns:
Variance result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.distance(signal)[source]
Computes signal traveled distance.
Calculates the total distance traveled by the signal using the hypotenuse between 2 datapoints.
Feature computational cost: 1
- signalnd-array
Input from which distance is computed
- float
Signal distance
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.ecdf(signal, d=10)[source]
Computes the values of ECDF (empirical cumulative distribution function) along the time axis.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which ECDF is computed
d (integer) – Number of ECDF values to return
- Returns:
The values of the ECDF along the time axis
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.ecdf_percentile(signal, percentile=[0.2, 0.8])[source]
Computes the percentile value of the ECDF.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which ECDF is computed
percentile (list) – Percentile value to be computed
- Returns:
The input value(s) of the ECDF
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.ecdf_percentile_count(signal, percentile=[0.2, 0.8])[source]
Computes the cumulative sum of samples that are less than the percentile.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which ECDF is computed
percentile (list) – Percentile threshold
- Returns:
The cumulative sum of samples
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.ecdf_slope(signal, p_init=0.5, p_end=0.75)[source]
Computes the slope of the ECDF between two percentiles. Possibility to return infinity values.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which ECDF is computed
p_init (float) – Initial percentile
p_end (float) – End percentile
- Returns:
The slope of the ECDF between two percentiles
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.entropy(signal, prob='standard')[source]
Computes the entropy of the signal using the Shannon Entropy.
Description in Article: Regularities Unseen, Randomness Observed: Levels of Entropy Convergence Authors: Crutchfield J. Feldman David
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which entropy is computed
prob (string) – Probability function (kde or gaussian functions are available)
- Returns:
The normalized entropy value
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.fft_mean_coeff(signal, fs, nfreq=256)[source]
Computes the mean value of each spectrogram frequency.
nfreq can not be higher than half signal length plus one. When it does, it is automatically set to half signal length plus one.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which fft mean coefficients are computed
fs (float) – Sampling frequency
nfreq (int) – The number of frequencies
- Returns:
The mean value of each spectrogram frequency
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.fundamental_frequency(signal, fs)[source]
Computes fundamental frequency of the signal.
The fundamental frequency integer multiple best explain the content of the signal spectrum.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which fundamental frequency is computed
fs (float) – Sampling frequency
- Returns:
f0 – Predominant frequency of the signal
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.hist(signal, nbins=10, r=1)[source]
Computes histogram of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from histogram is computed
nbins (int) – The number of equal-width bins in the given range
r (float) – The lower(-r) and upper(r) range of the bins
- Returns:
The values of the histogram
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.human_range_energy(signal, fs)[source]
Computes the human range energy ratio.
The human range energy ratio is given by the ratio between the energy in frequency 0.6-2.5Hz and the whole energy band.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Signal from which human range energy ratio is computed
fs (float) – Sampling frequency
- Returns:
Human range energy ratio
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.interq_range(signal)[source]
Computes interquartile range of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which interquartile range is computed
- Returns:
Interquartile range result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.kurtosis(signal)[source]
Computes kurtosis of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which kurtosis is computed
- Returns:
Kurtosis result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.lpcc(signal, n_coeff=12)[source]
Computes the linear prediction cepstral coefficients.
Implementation details and description in: http://www.practicalcryptography.com/miscellaneous/machine-learning/tutorial-cepstrum-and-lpccs/
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from linear prediction cepstral coefficients are computed
n_coeff (int) – Number of coefficients
- Returns:
Linear prediction cepstral coefficients
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.max_frequency(signal, fs)[source]
Computes maximum frequency of the signal.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Input from which maximum frequency is computed
fs (float) – Sampling frequency
- Returns:
0.95 of maximum frequency using cumsum
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.max_power_spectrum(signal, fs)[source]
Computes maximum power spectrum density of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which maximum power spectrum is computed
fs (float) – Sampling frequency
- Returns:
Max value of the power spectrum density
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.mean_abs_deviation(signal)[source]
Computes mean absolute deviation of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which mean absolute deviation is computed
- Returns:
Mean absolute deviation result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.mean_abs_diff(signal)[source]
Computes mean absolute differences of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which mean absolute deviation is computed
- Returns:
Mean absolute difference result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.mean_diff(signal)[source]
Computes mean of differences of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which mean of differences is computed
- Returns:
Mean difference result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.median_abs_deviation(signal)[source]
Computes median absolute deviation of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which median absolute deviation is computed
- Returns:
Mean absolute deviation result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.median_abs_diff(signal)[source]
Computes median absolute differences of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which median absolute difference is computed
- Returns:
Median absolute difference result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.median_diff(signal)[source]
Computes median of differences of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which median of differences is computed
- Returns:
Median difference result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.median_frequency(signal, fs)[source]
Computes median frequency of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which median frequency is computed
fs (int) – Sampling frequency
- Returns:
f_median – 0.50 of maximum frequency using cumsum.
- Return type:
int
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.mfcc(signal, fs, pre_emphasis=0.97, nfft=512, nfilt=40, num_ceps=12, cep_lifter=22)[source]
Computes the MEL cepstral coefficients.
It provides the information about the power in each frequency band.
Implementation details and description on: https://www.kaggle.com/ilyamich/mfcc-implementation-and-tutorial https://haythamfayek.com/2016/04/21/speech-processing-for-machine-learning.html#fnref:1
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which MEL coefficients is computed
fs (float) – Sampling frequency
pre_emphasis (float) – Pre-emphasis coefficient for pre-emphasis filter application
nfft (int) – Number of points of fft
nfilt (int) – Number of filters
num_ceps (int) – Number of cepstral coefficients
cep_lifter (int) – Filter length
- Returns:
MEL cepstral coefficients
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.negative_turning(signal)[source]
Computes number of negative turning points of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which minimum number of negative turning points are counted
- Returns:
Number of negative turning points
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.neighbourhood_peaks(signal, n=10)[source]
Computes the number of peaks from a defined neighbourhood of the signal.
- Reference: Christ, M., Braun, N., Neuffer, J. and Kempa-Liehr A.W. (2018). Time Series FeatuRe Extraction on basis
of Scalable Hypothesis tests (tsfresh – A Python package). Neurocomputing 307 (2018) 72-77
- Parameters:
signal (nd-array) – Input from which the number of neighbourhood peaks is computed
n (int) – Number of peak’s neighbours to the left and to the right
- Returns:
The number of peaks from a defined neighbourhood of the signal
- Return type:
int
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.pk_pk_distance(signal)[source]
Computes the peak to peak distance.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which peak to peak is computed
- Returns:
peak to peak distance
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.positive_turning(signal)[source]
Computes number of positive turning points of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which positive turning points are counted
- Returns:
Number of positive turning points
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.power_bandwidth(signal, fs)[source]
Computes power spectrum density bandwidth of the signal.
It corresponds to the width of the frequency band in which 95% of its power is located.
Description in article: Power Spectrum and Bandwidth Ulf Henriksson, 2003 Translated by Mikael Olofsson, 2005
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which the power bandwidth computed
fs (float) – Sampling frequency
- Returns:
Occupied power in bandwidth
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.rms(signal)[source]
Computes root mean square of the signal.
Square root of the arithmetic mean (average) of the squares of the original values.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which root mean square is computed
- Returns:
Root mean square
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.skewness(signal)[source]
Computes skewness of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which skewness is computed
- Returns:
Skewness result
- Return type:
int
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.slope(signal)[source]
Computes the slope of the signal.
Slope is computed by fitting a linear equation to the observed data.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which linear equation is computed
- Returns:
Slope
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_centroid(signal, fs)[source]
Barycenter of the spectrum.
Description and formula in Article: The Timbre Toolbox: Extracting audio descriptors from musicalsignals Authors Peeters G., Giordano B., Misdariis P., McAdams S.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Signal from which spectral centroid is computed
fs (int) – Sampling frequency
- Returns:
Centroid
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_decrease(signal, fs)[source]
Represents the amount of decreasing of the spectra amplitude.
Description and formula in Article: The Timbre Toolbox: Extracting audio descriptors from musicalsignals Authors Peeters G., Giordano B., Misdariis P., McAdams S.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Signal from which spectral decrease is computed
fs (float) – Sampling frequency
- Returns:
Spectral decrease
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_distance(signal, fs)[source]
Computes the signal spectral distance.
Distance of the signal’s cumulative sum of the FFT elements to the respective linear regression.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Signal from which spectral distance is computed
fs (float) – Sampling frequency
- Returns:
spectral distance
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_entropy(signal, fs)[source]
Computes the spectral entropy of the signal based on Fourier transform.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which spectral entropy is computed
fs (float) – Sampling frequency
- Returns:
The normalized spectral entropy value
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_kurtosis(signal, fs)[source]
Measures the flatness of a distribution around its mean value.
Description and formula in Article: The Timbre Toolbox: Extracting audio descriptors from musicalsignals Authors Peeters G., Giordano B., Misdariis P., McAdams S.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Signal from which spectral kurtosis is computed
fs (float) – Sampling frequency
- Returns:
Spectral Kurtosis
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_positive_turning(signal, fs)[source]
Computes number of positive turning points of the fft magnitude signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which the number of positive turning points of the fft magnitude are computed
fs (float) – Sampling frequency
- Returns:
Number of positive turning points
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_roll_off(signal, fs)[source]
Computes the spectral roll-off of the signal.
The spectral roll-off corresponds to the frequency where 95% of the signal magnitude is contained below of this value.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Signal from which spectral roll-off is computed
fs (float) – Sampling frequency
- Returns:
Spectral roll-off
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_roll_on(signal, fs)[source]
Computes the spectral roll-on of the signal.
The spectral roll-on corresponds to the frequency where 5% of the signal magnitude is contained below of this value.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Signal from which spectral roll-on is computed
fs (float) – Sampling frequency
- Returns:
Spectral roll-on
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_skewness(signal, fs)[source]
Measures the asymmetry of a distribution around its mean value.
Description and formula in Article: The Timbre Toolbox: Extracting audio descriptors from musicalsignals Authors Peeters G., Giordano B., Misdariis P., McAdams S.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Signal from which spectral skewness is computed
fs (float) – Sampling frequency
- Returns:
Spectral Skewness
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_slope(signal, fs)[source]
Computes the spectral slope.
Spectral slope is computed by finding constants m and b of the function aFFT = mf + b, obtained by linear regression of the spectral amplitude.
Description and formula in Article: The Timbre Toolbox: Extracting audio descriptors from musicalsignals Authors Peeters G., Giordano B., Misdariis P., McAdams S.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Signal from which spectral slope is computed
fs (float) – Sampling frequency
- Returns:
Spectral Slope
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_spread(signal, fs)[source]
Measures the spread of the spectrum around its mean value.
Description and formula in Article: The Timbre Toolbox: Extracting audio descriptors from musicalsignals Authors Peeters G., Giordano B., Misdariis P., McAdams S.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Signal from which spectral spread is computed.
fs (float) – Sampling frequency
- Returns:
Spectral Spread
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.spectral_variation(signal, fs)[source]
Computes the amount of variation of the spectrum along time.
Spectral variation is computed from the normalized cross-correlation between two consecutive amplitude spectra.
Description and formula in Article: The Timbre Toolbox: Extracting audio descriptors from musicalsignals Authors Peeters G., Giordano B., Misdariis P., McAdams S.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Signal from which spectral variation is computed.
fs (float) – Sampling frequency
- Returns:
Spectral Variation
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.sum_abs_diff(signal)[source]
Computes sum of absolute differences of the signal.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which sum absolute difference is computed
- Returns:
Sum absolute difference result
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.wavelet_abs_mean(signal, function=<function ricker>, widths=array([1, 2, 3, 4, 5, 6, 7, 8, 9]))[source]
Computes CWT absolute mean value of each wavelet scale.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Input from which CWT is computed
function (wavelet function) – Default: scipy.signal.ricker
widths (nd-array) – Widths to use for transformation Default: np.arange(1,10)
- Returns:
CWT absolute mean value
- Return type:
tuple
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.wavelet_energy(signal, function=<function ricker>, widths=array([1, 2, 3, 4, 5, 6, 7, 8, 9]))[source]
Computes CWT energy of each wavelet scale.
Implementation details: https://stackoverflow.com/questions/37659422/energy-for-1-d-wavelet-in-python
Feature computational cost: 2
- Parameters:
signal (nd-array) – Input from which CWT is computed
function (wavelet function) – Default: scipy.signal.ricker
widths (nd-array) – Widths to use for transformation Default: np.arange(1,10)
- Returns:
CWT energy
- Return type:
tuple
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.wavelet_entropy(signal, function=<function ricker>, widths=array([1, 2, 3, 4, 5, 6, 7, 8, 9]))[source]
Computes CWT entropy of the signal.
Implementation details in: https://dsp.stackexchange.com/questions/13055/how-to-calculate-cwt-shannon-entropy B.F. Yan, A. Miyamoto, E. Bruhwiler, Wavelet transform-based modal parameter identification considering uncertainty
Feature computational cost: 2
- Parameters:
signal (nd-array) – Input from which CWT is computed
function (wavelet function) – Default: scipy.signal.ricker
widths (nd-array) – Widths to use for transformation Default: np.arange(1,10)
- Returns:
wavelet entropy
- Return type:
float
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.wavelet_std(signal, function=<function ricker>, widths=array([1, 2, 3, 4, 5, 6, 7, 8, 9]))[source]
Computes CWT std value of each wavelet scale.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Input from which CWT is computed
function (wavelet function) – Default: scipy.signal.ricker
widths (nd-array) – Widths to use for transformation Default: np.arange(1,10)
- Returns:
CWT std
- Return type:
tuple
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.wavelet_var(signal, function=<function ricker>, widths=array([1, 2, 3, 4, 5, 6, 7, 8, 9]))[source]
Computes CWT variance value of each wavelet scale.
Feature computational cost: 2
- Parameters:
signal (nd-array) – Input from which CWT is computed
function (wavelet function) – Default: scipy.signal.ricker
widths (nd-array) – Widths to use for transformation Default: np.arange(1,10)
- Returns:
CWT variance
- Return type:
tuple
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features.zero_cross(signal)[source]
Computes Zero-crossing rate of the signal.
Corresponds to the total number of times that the signal changes from positive to negative or vice versa.
Feature computational cost: 1
- Parameters:
signal (nd-array) – Input from which the zero-crossing rate are computed
- Returns:
Number of times that signal value cross the zero axis
- Return type:
int
ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_settings module
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_settings.get_features_by_domain(domain=None, json_path=None)[source]
Creates a dictionary with the features settings by domain.
- Parameters:
domain (string) – Available domains: “statistical”; “spectral”; “temporal” If domain equals None, then the features settings from all domains are returned.
json_path (string) – Directory of json file. Default: package features.json directory
- Returns:
Dictionary with the features settings
- Return type:
Dict
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_settings.get_features_by_tag(tag=None, json_path=None)[source]
Creates a dictionary with the features settings by tag.
- Parameters:
tag (string) – Available tags: “audio”; “inertial”, “ecg”; “eeg”; “emg”. If tag equals None then, all available features are returned.
json_path (string) – Directory of json file. Default: package features.json directory
- Returns:
Dictionary with the features settings
- Return type:
Dict
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_settings.get_number_features(dict_features)[source]
Count the total number of features based on input parameters of each feature
- Parameters:
dict_features (dict) – Dictionary with features settings
- Returns:
Feature vector size
- Return type:
int
ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils module
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.autocorr_norm(signal)[source]
Computes the autocorrelation.
Implementation details and description in: https://ccrma.stanford.edu/~orchi/Documents/speaker_recognition_report.pdf
- Parameters:
signal (nd-array) – Input from linear prediction coefficients are computed
- Returns:
Autocorrelation result
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.calc_ecdf(signal)[source]
Computes the ECDF of the signal.
- Parameters:
signal (nd-array) – Input from which ECDF is computed
- Returns:
Sorted signal and computed ECDF.
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.calc_fft(signal, fs)[source]
This functions computes the fft of a signal.
- Parameters:
signal (nd-array) – The input signal from which fft is computed
fs (float) – Sampling frequency
- Returns:
f (nd-array) – Frequency values (xx axis)
fmag (nd-array) – Amplitude of the frequency values (yy axis)
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.compute_time(signal, fs)[source]
Creates the signal correspondent time array.
- Parameters:
signal (nd-array) – Input from which the time is computed.
fs (int) – Sampling Frequency
- Returns:
time – Signal time
- Return type:
float list
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.create_symmetric_matrix(acf, order=11)[source]
Computes a symmetric matrix.
Implementation details and description in: https://ccrma.stanford.edu/~orchi/Documents/speaker_recognition_report.pdf
- Parameters:
acf (nd-array) – Input from which a symmetric matrix is computed
order (int) – Order
- Returns:
Symmetric Matrix
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.create_xx(features)[source]
Computes the range of features amplitude for the probability density function calculus.
- Parameters:
features (nd-array) – Input features
- Returns:
range of features amplitude
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.filterbank(signal, fs, pre_emphasis=0.97, nfft=512, nfilt=40)[source]
Computes the MEL-spaced filterbank.
It provides the information about the power in each frequency band.
Implementation details and description on: https://www.kaggle.com/ilyamich/mfcc-implementation-and-tutorial https://haythamfayek.com/2016/04/21/speech-processing-for-machine-learning.html#fnref:1
- Parameters:
signal (nd-array) – Input from which filterbank is computed
fs (float) – Sampling frequency
pre_emphasis (float) – Pre-emphasis coefficient for pre-emphasis filter application
nfft (int) – Number of points of fft
nfilt (int) – Number of filters
- Returns:
MEL-spaced filterbank
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.gaussian(features)[source]
Computes the probability density function of the input signal using a Gaussian function
- Parameters:
features (nd-array) – Input from which probability density function is computed
- Returns:
probability density values
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.kde(features)[source]
Computes the probability density function of the input signal using a Gaussian KDE (Kernel Density Estimate)
- Parameters:
features (nd-array) – Input from which probability density function is computed
- Returns:
probability density values
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.lpc(signal, n_coeff=12)[source]
Computes the linear prediction coefficients.
Implementation details and description in: https://ccrma.stanford.edu/~orchi/Documents/speaker_recognition_report.pdf
- Parameters:
signal (nd-array) – Input from linear prediction coefficients are computed
n_coeff (int) – Number of coefficients
- Returns:
Linear prediction coefficients
- Return type:
nd-array
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.set_domain(key, value)[source]
- ltsm.prompt_reader.stat_prompt.tsfel.feature_extraction.features_utils.wavelet(signal, function=<function ricker>, widths=array([1, 2, 3, 4, 5, 6, 7, 8, 9]))[source]
Computes CWT (continuous wavelet transform) of the signal.
- Parameters:
signal (nd-array) – Input from which CWT is computed
function (wavelet function) – Default: scipy.signal.ricker
widths (nd-array) – Widths to use for transformation Default: np.arange(1,10)
- Returns:
The result of the CWT along the time axis matrix with size (len(widths),len(signal))
- Return type:
nd-array