semantrix / tracking.py
Javierss
Add hybrid model method and languages
5320625
raw
history blame
726 Bytes
import numpy as np
def calculate_moving_average(scores, window_size):
# Convert the scores list to a NumPy array for better performance
scores_array = np.array(scores)
# Create an array of rolling windows using the np.convolve function
moving_averages = np.around(
np.convolve(scores_array, np.ones(window_size) / window_size, mode="valid"), 2
)
return list(moving_averages)
def calculate_tendency_slope(scores):
# Convert the scores list to a NumPy array for better performance
scores_array = np.array(scores)
# Calculate the first derivative (slope) of the scores
derivative = np.around(np.gradient(scores_array), 2)
return list(derivative)