-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprediction_generator.py
More file actions
147 lines (110 loc) · 5.55 KB
/
prediction_generator.py
File metadata and controls
147 lines (110 loc) · 5.55 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import sys
import sql
import datetime
import time
import argparse
import sqlite3
PRED_GEN_VERSION = '0.5'
'''
This program will output all the home team the predictions over/under for a week.
input arguments: Date to run. The result column only shows up if the date selected
was from the past.
Output:
Season: 2016, Week: 17
Home team list for week: 17
['ATL', 'MIN', 'IND', 'PHI', 'DET', 'MIA', 'NYJ', 'TAM', 'WAS', 'TEN', 'CIN', 'PIT', 'LAC', 'DEN', 'SFO', 'LAR']
Home team Prediction Predicted result Actual total Margin Calc Avg Vegas Line
ATL Over Correct Over 70 4.2 62.8 58.5 Past Game
MIN Under Wrong Under 48 -8.3 35.7 44.0 Past Game
IND Under Correct Under 44 -1.4 47.1 48.5 Past Game
Correct Over 44
Wrong Over 22
Correct Under 55
Wrong Under 21
Off 3
------------------
Go through each team durring the season to deturmine who is on a streak
'''
if __name__ == '__main__':
s = sql.Sql('games.db')
parser = argparse.ArgumentParser(description='Predicts sports outcomes.', prog='prediction_generator.py')
parser.add_argument('-s', '--season', type=str, action='store', required=True, help="season in the form: 2015-2016")
parser.add_argument('-w', '--week', type=str, action='store', required=True, help='Week of season: 1')
parser.add_argument('-v', '--version', action='version', version='%(prog)s' + PRED_GEN_VERSION)
args = parser.parse_args()
season, week = [args.season, args.week]
print "\nSeason: %s, Week: %s" % (season, week)
home_team_list = s.get_home_team_list_for_season_week2(season, week)
print "Home team list for week:", week
print home_team_list
print "Home team Prediction Predicted result Actual total Margin Calc Avg Vegas Line Past or Pending"
over_correct_cnt = 0
over_wrong_cnt = 0
under_correct_cnt = 0
under_wrong_cnt = 0
did_not_play_cnt = 0
over_pushed_cnt = 0
under_pushed_cnt = 0
conn = sqlite3.connect('game_results.db')
c = conn.cursor()
for home_team in home_team_list:
details = s.get_targeted_game_details3(home_team, season, week)
#print "Home team:", home_team
#print "Details:", details
#print "Predicted:",
if details['margin'] > 0:
prediction = "Over"
elif details['margin'] < 0:
prediction = "Under"
else:
prediction = "Dont play"
predicted_result = "No Action"
# print "Predicted:",
streaking_team = 'The streaking team'
#here is where I start trying to add this in the database testing
if details['margin'] != 0:
on_streak_text = "Is on a streak!"
on_streak = streaking_team
if details['margin'] > 0 and float(details['actual_total']) > details['ou_total']:
predicted_result = "Correct Over"
over_correct_cnt += 1
if details['margin'] < 0 and float(details['actual_total']) < details['ou_total']:
predicted_result = "Correct Under"
under_correct_cnt += 1
if details['margin'] > 0 and float(details['actual_total']) < details['ou_total']:
predicted_result = "Wrong Over"
over_wrong_cnt += 1
if details['margin'] < 0 and float(details['actual_total']) > details['ou_total']:
predicted_result = "Wrong Under"
under_wrong_cnt += 1
if details['margin'] > 0 and float(details['actual_total']) == details['ou_total']:
predicted_result = "Pushed Over"
over_pushed_cnt += 1
if details['margin'] > 0 and float(details['actual_total']) == details['ou_total']:
predicted_result = "Pushed Under"
under_pushed_cnt += 1
if details['margin'] < 0 and float(details['actual_total']) == details['ou_total']:
predicted_result = "Pushed Under"
under_pushed_cnt += 1
elif details['margin'] > 0 and float(details['actual_total']) == details['ou_total']:
predicted_result = "Did not play"
did_not_play_cnt += 1
# print "Actual total:", details['actual_total']
# print "Actual margin:", details['average']
if details['actual_total'] == '0':
final_result = "Pending Game"
elif details['average'] >= 0:
final_result = "Past Game"
print " %s\t %s\t %s\t %d\t%02.1f\t %02.1f\t %02.1f %s" % (home_team, prediction, predicted_result, details['actual_total'], details['margin'], details['average'], details['ou_total'], final_result)
streak_type = 'over'
teams_played = 'DAL WAS PHI'
coaching = 'sucks'
how_harry_did = 'won'
what_does_harry_have = 'Over'
cmd = "INSERT INTO game_results VALUES ('" + home_team + "','" + str(season) + "','" + str(week) + "','" + str(over_correct_cnt) + "','" + str(under_correct_cnt) + "','"\
+ str(over_wrong_cnt) + "','" + str(under_wrong_cnt) + "','"+ str(did_not_play_cnt) + "','" + str(over_pushed_cnt) + "','"\
+ str(under_pushed_cnt) + "','" + str(on_streak) + "','" + str(streak_type) + "','" + str(teams_played) + "','" + str(coaching) + "','" + str(how_harry_did) + "','" + str(what_does_harry_have) + "')"
print cmd
c.execute(cmd)
conn.commit()
conn.close()