Skip to content

Commit

Permalink
Bug fixed on percentile, spectral_kurtosis and spectral_skewness
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarandas committed Feb 2, 2022
1 parent 4917867 commit bdf4b4d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tsfel/feature_extraction/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ def ecdf_slope(signal, p_init=0.5, p_end=0.75):

@set_domain("domain", "statistical")
@vectorize
def ecdf_percentile(signal, percentile=None):
def ecdf_percentile(signal, percentile=[0.2, 0.8]):
"""Computes the percentile value of the ECDF.
Feature computational cost: 1
Expand All @@ -827,8 +827,6 @@ def ecdf_percentile(signal, percentile=None):
percentile = eval(percentile)
if isinstance(percentile, (float, int)):
percentile = [percentile]
if isinstance(percentile, (str)):
percentile = [float(percentile)]

# calculate ecdf
x, y = calc_ecdf(signal)
Expand All @@ -849,7 +847,7 @@ def ecdf_percentile(signal, percentile=None):

@set_domain("domain", "statistical")
@vectorize
def ecdf_percentile_count(signal, percentile=None):
def ecdf_percentile_count(signal, percentile=[0.2, 0.8]):
"""Computes the cumulative sum of samples that are less than the percentile.
Feature computational cost: 1
Expand Down Expand Up @@ -1144,9 +1142,9 @@ def spectral_kurtosis(signal, fs):
f, fmag = calc_fft(signal, fs)
spect_centr = spectral_centroid(signal, fs)
spread = spectral_spread(signal, fs)
summedFmag = match_last_dim_by_value_repeat(np.sum(fmag, axis=-1), fmag)

spect_kurt = ((f - match_last_dim_by_value_repeat(spect_centr, f)) ** 4) * (fmag / summedFmag)
summedFmag = match_last_dim_by_value_repeat(np.sum(fmag, axis=-1), fmag)
spect_kurt = ((f - match_last_dim_by_value_repeat(spect_centr, f)) ** 4) * devide_keep_zero(fmag, summedFmag)
return devide_keep_zero(np.sum(spect_kurt, axis=-1), spread ** 4)


Expand Down Expand Up @@ -1177,7 +1175,7 @@ def spectral_skewness(signal, fs):
spect_centr = spectral_centroid(signal, fs)
summedFmag = match_last_dim_by_value_repeat(np.sum(fmag, axis=-1), fmag)

skew = ((f - match_last_dim_by_value_repeat(spect_centr, f)) ** 3) * (fmag / summedFmag)
skew = ((f - match_last_dim_by_value_repeat(spect_centr, f)) ** 3) * devide_keep_zero(fmag, summedFmag)
return devide_keep_zero(np.sum(skew, axis=-1), spectral_spread(signal, fs) ** 3)


Expand Down

0 comments on commit bdf4b4d

Please sign in to comment.