lab4-rc1
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
#import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
for i in range(1, 4):
|
||||
exec(f"data{i} = list(zip(*[x for x in [[float(j) for j in k.strip().split(',')] for k in open(\"data{i}.csv\").read().split(\"\\n\")[1:] if k] if x[1] <= 1200]))")
|
||||
|
||||
'''
|
||||
print(data1)
|
||||
print(data2)
|
||||
print(data3)
|
||||
'''
|
||||
|
||||
'''
|
||||
for i in range(5):
|
||||
title = "S,D,D_avg,T,C".split(',')[i]
|
||||
plt.cla()
|
||||
plt.figure(figsize = (17/1.3, 11.2/1.3))
|
||||
plt.title(title)
|
||||
plt.plot(data1[1], data1[i+3])
|
||||
plt.plot(data2[1], data2[i+3])
|
||||
plt.plot(data3[1], data3[i+3])
|
||||
plt.legend(labels = ["Кільце", "Дерево", "Решітка"])
|
||||
plt.xlim(0, 1100)
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
#plt.savefig(f"diagram-{title}.svg", format = 'svg')
|
||||
'''
|
||||
|
||||
splits = 0, 55, 240, 1100
|
||||
|
||||
|
||||
vsss = []
|
||||
smas = []
|
||||
for i in range(3):
|
||||
def get_avgs(d):
|
||||
s = tuple(zip(*[j for j in zip(*d) if j[1] >= splits[i] and j[1] < splits[i+1]]))
|
||||
vs = []
|
||||
for v in range(5):
|
||||
vs.append(sum(s[v+3]) / len(s[v+3]))
|
||||
print(round(vs[-1], 7), end = " ")
|
||||
|
||||
print()
|
||||
|
||||
return vs
|
||||
|
||||
vss = []
|
||||
print(f"Range {splits[i]}-{splits[i+1]}")
|
||||
for x in range(3):
|
||||
exec(f"vss.append(get_avgs(data{x+1}))")
|
||||
|
||||
vals = list(zip(*vss))
|
||||
print("Normed:")
|
||||
t = []
|
||||
for v in vals:
|
||||
m = min(v)
|
||||
# if (m < 1.0):
|
||||
# v = [(2 - x) for x in v]
|
||||
# m = min(v)
|
||||
#
|
||||
# t.append([x / m for x in v])
|
||||
# print([round(x, 5) for x in t[-1]])
|
||||
# else:
|
||||
t.append([x / m for x in v])
|
||||
print([round(x, 5) for x in t[-1]])
|
||||
|
||||
|
||||
t = zip(*t)
|
||||
print("Sigmas:")
|
||||
smas.append([])
|
||||
for v in t:
|
||||
smas[-1].append(sum(v))
|
||||
print(round(smas[-1][-1], 5), end = " ")
|
||||
|
||||
print()
|
||||
print()
|
||||
|
||||
vsss.append(vss)
|
||||
|
||||
#tsas = []
|
||||
#colors = ['#1133FF', '#22DD33', '#EE6611']
|
||||
#for i, c in zip(zip(*smas), colors):
|
||||
#tsas += i
|
||||
# plt.grouped_bar([f"Діапазон {i+1}" for i in range(3)], i, color = c)
|
||||
|
||||
#tsas = tuple(zip(*smas))
|
||||
dsas = {i:v for i, v in zip([f"Діапазон {i+1}" for i in range(3)], smas)}
|
||||
print(dsas)
|
||||
plt.cla()
|
||||
plt.figure(figsize = (17/1.4, 17/1.4))
|
||||
plt.grouped_bar(dsas, bar_spacing = 0.25, tick_labels = ["Кільце", "Дерево", "Решітка"])
|
||||
plt.legend()
|
||||
plt.tight_layout()
|
||||
#plt.show()
|
||||
plt.savefig("histogram.svg", format = "svg")
|
||||
|
||||
|
||||
#plt.grouped_bar({i:v for i, v in zip([f"Діапазон {i+1}" for i in range(3)], smas)}, colors = colors)
|
||||
|
||||
|
||||
#plt.show()
|
||||
#print(tsas)
|
||||
Reference in New Issue
Block a user