Untitled
unknown
plain_text
2 years ago
876 B
10
Indexable
import numpy as np
def cooldown(signal, cooldown=60):
# Convert the signal column to a NumPy array if it's not already
signal_array = np.array(signal)
cooldown_counter = 0
for i in range(len(signal_array)):
if signal_array[i] == 1:
# If a signal is found, set the cooldown counter to the cooldown period
cooldown_counter = cooldown
elif cooldown_counter > 0:
# If we are within the cooldown period (but the current signal is not 1),
# we decrement the cooldown counter and set the current signal to 1
signal_array[i] = 1
cooldown_counter -= 1
# If cooldown_counter is 0, do nothing (signal stays as is)
return signal_array
# Compute the signal
signal = trainer.predict(X_test)
signal= cooldown(signal,60)Editor is loading...
Leave a Comment