Commit 70a324d1 authored by Sanchit's avatar Sanchit

uploading q1-d and some part of q5

parent 533bbf2a
......@@ -95,7 +95,27 @@ def alohomora(n, m):
# 'axis': str; axis ∈ {'X','Y','Z'}
# return type: float Ndarray; dim: Nx3
def expelliarmus(arr, theta, axis):
pass
angle = np.radians(-theta)
c, s = np.cos(angle), np.sin(angle)
rot_array_x = np.array([[1, 0, 0],
[0, c, -s],
[0, s, c]])
rot_array_y = np.array([[c, 0, s],
[0, 1, 0],
[-s, 0, c]])
rot_array_z = np.array([[c, -s, 0],
[s, c, 0],
[0, 0, 1]])
if axis == 'X':
res = np.dot(mat, rot_array_x)
return (res.round(decimals=2))
if axis == 'Y':
res = np.dot(mat, rot_array_y)
return (res.round(decimals=2))
if axis == 'Z':
res = np.dot(mat, rot_array_z)
return (res.round(decimals=2))
# ---- Task (e) -------
......
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import csv
i1=[]
i2=[]
i3=[]
with open('data.csv', newline='') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
if row[0] == "instance-1":
i1.append(row)
elif row[0] == "instance-2":
i2.append(row)
elif row[0] == "instance-3":
i3.append(row)
instance_1=pd.DataFrame(i1)
instance_1.columns=['instance','algorithm','random_seed','epsilon','horizon','regret']
instance_2=pd.DataFrame(i2)
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))
for key, grp in instance_1.groupby(['algorithm']):
ax.plot(grp['horizon'], grp['regret'], label=key, marker='o')
ax.legend()
plt.xscale("log")
plt.yscale("log")
plt.show()
#grouped_df=instance_1.groupby(['algorithm'])
#for key, item in grouped_df:
#print(grouped_df.get_group(key), "\n\n")
#instance_1.plot(kind='scatter',x='horizon',y='regret',color='red')
#plt.xscale("log")
#plt.yscale("log")
#plt.show()
#data.groupby(level="instance",axis=0)
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