Last active
September 18, 2020 21:53
-
-
Save josephbima/7bcced8ceefc7477351e55667e2ad892 to your computer and use it in GitHub Desktop.
This code extracts the feature we have chosen from the data (window)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def _compute_mean_features(window): | |
| """ | |
| Computes the mean x, y and z acceleration over the given window. | |
| """ | |
| return np.mean(window, axis=0) | |
| def _compute_std_features(window): | |
| ''' | |
| Computes the standard deviation of x, y and z acceleration over the given window. | |
| Returns an array of numbers corresponding to the x, y and z values | |
| ''' | |
| return np.std(window, axis = 0) | |
| def _compute_dominant_frequency(window): | |
| ''' | |
| Computes the dominant frequency of x, y and z acceleration over the given window. | |
| ''' | |
| return np.fft.rfft(window,axis=0).astype(float)[0] | |
| def _compute_peak_length(window): | |
| ''' | |
| Computes the peak length of x, y and z acceleration over the given window. | |
| ''' | |
| magnitude = _compute_magnitude(window) | |
| peaks, _ = find_peaks(magnitude, prominence=1) | |
| return [len(peaks)] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment