forked from vnguyen5/MLB-Machine-Learning-Sports-Betting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.py
24 lines (21 loc) · 704 Bytes
/
stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Stats:
def __init__(self):
self.runs = 0
self.ab = 0
self.hits = 0
self.doubles = 0
self.triples = 0
self.homeruns = 0
self.hbp = 0
self.bb = 0
self.ibb = 0
self.ks = 0
self.sb = 0
self.cs = 0
self.sac_fly = 0
def onbase(self):
return (self.hits + self.bb + self.ibb + self.hbp) / (self.ab + self.bb + self.ibb + self.hbp + self.sac_fly)
def slugging(self):
return ((self.hits - self.doubles - self.triples - self.homeruns) + 2 * self.doubles + 3 * self.triples + 4 * self.homeruns) / self.ab
def ops(self):
return self.onbase() + self.slugging()