aeon
aeon copied to clipboard
[ENH] Parallel PAA & SAX transform
Describe the feature or idea you want to propose
Sax transform currently have n_jobs but use it only for inverse transform. We should also use it for the transform step.
Describe your proposed solution
We should introduce numba parallel replacements for _get_sax_symbols(self, X_paa) and also introduce n_jobs to PAA.
These functions are fairly simple to parallelize. For exemple the sax symbols (replace uint8 with appropriate dtype):
@njit(fastmath=True, cache=True, parallel=True)
def _get_sax_symbols(X, breakpoints):
n_cases, n_channels, n_timepoints = X.shape
X_new = np.zeros((n_cases, n_channels, n_timepoints), dtype=np.uint8)
n_break = breakpoints.shape[0] - 1
for i_x in prange(n_cases):
for i_c in prange(n_channels):
for i_b in prange(n_break):
mask = np.where(
(X[i_x,i_c] >= breakpoints[i_b]) & (X[i_x,i_c] < breakpoints[i_b + 1])
)[0]
X_new[i_x, i_c, mask] += np.uint8(i_b)
return X_new
Describe alternatives you've considered, if relevant
No response
Additional context
No response