-
-
Save tkeyo/fbfe5d63c5b71b1faaa6fa5621b0b451 to your computer and use it in GitHub Desktop.
This file contains 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
inference_list = [] | |
DEBOUNCE_THRESHOLD = 9 | |
TIME_DIFF = 450 #ms | |
for st in inference_step: # looping through the whole length of the dataset | |
inference = model.score(data) | |
if inference in [1,2,3]: | |
inference_list.append((time, inference)) | |
# if there are more or equal than 9 predictions in a list | |
# AND | |
# the difference between the first and last predictions is > 450 ms | |
if len(inference_list) >= DEBOUNCE_THRESHOLD and (inference_list[-1][0] - inference_list[0][0]) >= TIME_DIFF: | |
inferences = [x[1] for x in inferences_list[:DEBOUNCE_THRESHOLD]] # gets the first 8 predictions | |
inference_final = max(set(inferences), key=inferences.count) # gets the most frequent value | |
inference_list = [] # cleans up the list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment