-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict-SRH.py
More file actions
58 lines (58 loc) · 1.3 KB
/
Copy pathpredict-SRH.py
File metadata and controls
58 lines (58 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import csv
from statsmodels.tsa.ar_model import AR
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt1
rows=[]
filename="deliveries.csv"
with open(filename, 'r',encoding="utf-8") as csvfile:
csvreader = csv.reader(csvfile)
fields = next(csvreader)
for row in csvreader:
rows.append(row)
match = []
prev='1'
temp=0
x = []
y = []
all_x = []
all_y = []
bno=0
for row in rows:
if(row[2]=="Sunrisers Hyderabad"):
if(prev==row[0]):
temp+=int(row[17])
else:
bno=1
all_x.append(x)
all_y.append(y)
x=[]
y=[]
match.append(temp)
temp=int(row[17])
prev=row[0]
x.append(bno)
y.append(temp)
bno+=1
run_on_ball = [[]]
arr=[]
for i in range(131):
run_on_ball.append([])
for i in range(131):
for j in range(len(all_y)):
if(i<len(all_y[j]) and len(all_y[j])>=120):
run_on_ball[i].append(all_y[j][i])
x_corr= []
for i in range(75):
x_corr.append(i+1)
for i in range(131):
rang=len(run_on_ball[i])
x1=[]
y1=[]
for i in range(120):
data=run_on_ball[i]
model=AR(run_on_ball[i])
model_fit=model.fit()
x1.append(i+1)
y1.append(model_fit.predict(len(data),len(data)))
plt1.plot(x1,y1)
plt1.savefig('SRH-predict.jpg')