Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedup approx entropy #1107

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tsfresh/feature_extraction/feature_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import stumpy
from numpy.linalg import LinAlgError
from scipy.signal import cwt, find_peaks_cwt, ricker, welch
from scipy.spatial.distance import cdist
from scipy.stats import linregress
from statsmodels.tools.sm_exceptions import MissingDataError
from statsmodels.tsa.ar_model import AutoReg
Expand Down Expand Up @@ -1782,7 +1783,7 @@ def approximate_entropy(x, m, r):
def _phi(m):
x_re = np.array([x[i : i + m] for i in range(N - m + 1)])
C = np.sum(
np.max(np.abs(x_re[:, np.newaxis] - x_re[np.newaxis, :]), axis=2) <= r,
cdist(x_re, x_re, metric="chebyshev") <= r,
axis=0,
) / (N - m + 1)
return np.sum(np.log(C)) / (N - m + 1.0)
Expand Down
Loading