You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
import sys
|
|
import os
|
|
import yaml
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
|
|
def s_a(n):
|
|
return sum(n)/len(n)
|
|
|
|
def mediana(n):
|
|
while len(n) >2:
|
|
n.remove(min(n))
|
|
n.remove(max(n))
|
|
if len(n) == 2:
|
|
return s_a(n)
|
|
else:
|
|
return n[0]
|
|
|
|
|
|
def plot(ax, path, color):
|
|
scores =[]
|
|
|
|
for filename in sorted(os.listdir(path)):
|
|
file_path = os.path.join(path, filename)
|
|
# Check if it is a file and not a subdirectory
|
|
if os.path.isfile(file_path) and file_path.endswith('.yaml'):
|
|
with open(file_path, 'r', encoding='utf-8') as file:
|
|
data = yaml.load(file, Loader = yaml.Loader)
|
|
scores.append(data['score'])
|
|
#scores.append(data['score']/data['total_time'])
|
|
|
|
|
|
ax.plot(range(1, len(scores)+1),scores, '.-', label=f"{path.split('/')[-1]}'s scores", color = color)
|
|
ax.plot((1, len(scores)),(s_a(scores), s_a(scores)), '--', label=f"{path.split('/')[-1]}'s mean ({round(s_a(scores), 3)})", color = color)
|
|
ax.plot((1, len(scores)),(mediana(scores), mediana(scores)), ':', label=f"{path.split('/')[-1]}'s mediana ({round(mediana(scores), 3)})", color = color)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
fig, ax = plt.subplots()
|
|
|
|
plot(ax, "/home/gestures/Easy_sim/dummy_simulation/stats/Dima", "limegreen")
|
|
plot(ax, "/home/gestures/Easy_sim/dummy_simulation/stats/Elisey", "red")
|
|
plot(ax, "/home/gestures/Easy_sim/dummy_simulation/stats/BOBA", "magenta")
|
|
plot(ax, "/home/gestures/Easy_sim/dummy_simulation/stats/Nika", "pink")
|
|
plot(ax, "/home/gestures/Easy_sim/dummy_simulation/stats/Sasha", "orange")
|
|
plot(ax, "/home/gestures/Easy_sim/dummy_simulation/stats/Christine", "blue")
|
|
|
|
ax.set(xlabel='№', ylabel='score')
|
|
ax.grid()
|
|
ax.legend()
|
|
ax.set_title("Scores of students in dummy simulation")
|
|
plt.show()
|