Моя первоначальная идея заключалась в том, чтобы объединить 5 оценок в массив формы (t, n, 5) достигается с помощью np.dstack. Не уверен, что это хорошая идея. Вот что у меня есть на данный момент:
Код: Выделить всё
import numpy as np
# Random data for demonstration
mat_1 = np.ones((20, 10))
mat_2 = np.ones((20, 10))
mat_3 = np.ones((20, 10))
mat_4 = np.ones((20, 10))
mat_5 = np.ones((20, 10))
matrix = [mat_1, mat_2, mat_3, mat_4]
my_list = np.dstack(matrix)
def radar_plot_area(data):
num_vars = len(data)
# Compute angle for each axis
angles = np.linspace(0, 2 * np.pi, num_vars, endpoint=False)
# Calculate area using shoelace formula
x = [r * np.cos(a) for r, a in zip(data, angles)]
y = [r * np.sin(a) for r, a in zip(data, angles)]
area = 0.5 * np.abs(np.sum(x * np.roll(y, -1)) - np.sum(x * np.roll(y, 1)))
return area
# Create output matrix
areas_matrix = np.zeros((20, 10))
for i in range(20):
for j in range(10):
areas_matrix[i][j] = radar_plot_area(my_list[i][j])
print(areas_matrix)
Код: Выделить всё
def radar_plot_area(*scores: np.array): #the inputs are the 5 scores (which are arrays) I mentioned
...
return area #output is a (t, n) matrix containing the areas for each character per day
Подробнее здесь: https://stackoverflow.com/questions/790 ... -arrays-in