Fixing spread and prediction collection
This commit is contained in:
parent
de8485cf37
commit
de57008596
@ -4,10 +4,10 @@ import json
|
||||
from tqdm import tqdm
|
||||
import re
|
||||
|
||||
def calcPredictedScore(sF,sU,S,O):
|
||||
def calcPredictedScore(S,O):
|
||||
scoreObj = {}
|
||||
scoreObj["sU"] = (int(O) - int(S))/2
|
||||
scoreObj["sF"] = int(O) - ((int(O)-int(S))/2)
|
||||
scoreObj["sU"] = (float(O) - float(S))/2
|
||||
scoreObj["sF"] = float(O) - ((float(O)-float(S))/2)
|
||||
return scoreObj
|
||||
|
||||
fullObj = []
|
||||
@ -24,6 +24,7 @@ for year in tqdm(range(start_year, 2025)):
|
||||
|
||||
try:
|
||||
for table in start_pos.find_all_next(class_="soh1"):
|
||||
week = table.find_previous("h3").string
|
||||
for child in table.find_all("tbody"):
|
||||
for row in child.find_all("tr"):
|
||||
cells = row.find_all("td")
|
||||
@ -44,22 +45,34 @@ for year in tqdm(range(start_year, 2025)):
|
||||
game["sF"] = actualScore.group(1)
|
||||
game["sU"] = actualScore.group(2)
|
||||
|
||||
spreadValSearch = re.search(r'.\s-?(\d+)', spreadText)
|
||||
spreadValSearch = re.search(r'.\s-?(\d*\.*\d)', spreadText)
|
||||
if spreadValSearch:
|
||||
spreadVal = spreadValSearch.group(1)
|
||||
else:
|
||||
spreadVal = -1
|
||||
|
||||
if cells[cursor+9].length is None:
|
||||
ouVal = None
|
||||
ou = []
|
||||
for t in cells[cursor+9].string.split():
|
||||
try:
|
||||
ou.append(float(t))
|
||||
except ValueError:
|
||||
pass
|
||||
if len(ou)>0:
|
||||
ouVal = ou[0]
|
||||
else:
|
||||
ouVal = cells[cursor+9].string
|
||||
ouVal = None
|
||||
|
||||
game["spread"] = spreadVal
|
||||
game["ou"] = ouVal
|
||||
|
||||
if spreadVal != -1 and ouVal:
|
||||
game["pScore"] = calcPredictedScore(game["sF"],game["sU"],spreadVal,ouVal)
|
||||
game["pScore"] = calcPredictedScore(spreadVal,ouVal)
|
||||
else:
|
||||
game["pScore"] = {}
|
||||
game["pScore"]["sF"] = None
|
||||
game["pScore"]["sU"] = None
|
||||
|
||||
game["week"] = week
|
||||
|
||||
fullObj.append(game)
|
||||
except Exception as e:
|
||||
@ -68,7 +81,7 @@ for year in tqdm(range(start_year, 2025)):
|
||||
|
||||
objson = json.dumps(fullObj, indent=4)
|
||||
|
||||
with open("src/data/odds_data_abbr.json", "w") as odds_file:
|
||||
with open("src/data/odds_data.json", "w") as odds_file:
|
||||
odds_file.write(
|
||||
objson
|
||||
)
|
||||
|
120957
src/data/odds_data.json
120957
src/data/odds_data.json
File diff suppressed because it is too large
Load Diff
153022
src/data/odds_data_abbr.json
153022
src/data/odds_data_abbr.json
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user