Commit 1db593a4 authored by Samarth Joshi's avatar Samarth Joshi

Updating q5

parent 55f0a4d6
......@@ -2,7 +2,32 @@ import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import csv
i1=[]
df = pd.read_csv("data.csv")
count=1
for instance_id, grp1 in df.groupby(['instance']):
if instance_id == 'instance-1' or True:
plt.figure(count)
count = count + 1
for algorithm, grp2 in grp1.groupby(['algorithm', 'epsilon']):
rlist = []
hlist = []
algo_label = algorithm[0]
if algorithm[1]:
algo_label = algo_label + " " + str(algorithm[1])
for horizon, grp3 in grp2.groupby(['horizon']):
hlist.append(horizon)
maxr = grp3['regret'].max()
rlist.append(grp3['regret'].apply(lambda x: maxr - x).sum())
plt.plot(hlist, rlist, label=algo_label)
plt.xscale("log")
plt.yscale("log")
plt.legend()
plt.savefig(f"instance{instance_id.split('-')[1]}.png")
""" i1=[]
i2=[]
i3=[]
with open('data.csv', newline='') as csvfile:
......@@ -21,14 +46,29 @@ instance_3=pd.DataFrame(i3)
#instance_1.set_index('horizon', inplace=True)
#instance_1.groupby(['algorithm'])['regret'].plot(legend=True)
fig, ax = plt.subplots(figsize=(12,5))
print(instance_1)
for key, grp in instance_1.groupby(['algorithm']):
plt.plot(grp['horizon'], grp['regret'], label=key, marker='o')
pass
for key, grp in instance_1.groupby(['algorithm']):
ax.plot(grp['horizon'], grp['regret'], label=key, marker='o')
hori_list = []
regreti_list = []
for hori, grp2 in grp.groupby(['horizon']):
regrmax = ((grp2['regret'].explode().astype(int).max()))
regreti = ((grp2['regret'].apply(lambda x: regrmax-int(x))).sum())
hori_list.append(hori)
regreti_list.append(regreti_list)
plt.plot(hori_list, regreti_list)
ax.legend()
plt.xscale("log")
plt.yscale("log")
plt.show()
"""
#plt.show()
#grouped_df=instance_1.groupby(['algorithm'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment