-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from matsonj/add-nfl-model
Add-nfl-model
- Loading branch information
Showing
283 changed files
with
22,508 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
/docs/run | ||
/data/data_catalog | ||
/output | ||
/logs | ||
/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Team,Win Total,ELO rating,Conf,Division | ||
Buffalo Bills,10.5,1729.76563718597,AFC,East | ||
Miami Dolphins,9.5,1681.13241410486,AFC,East | ||
New York Jets,9.5,1676.81962490493,AFC,East | ||
New England Patriots,7.5,1605.49738694507,AFC,East | ||
Cincinnati Bengals,11.5,1717.78586912306,AFC,North | ||
Baltimore Ravens,8.5,1589.99596421381,AFC,North | ||
Cleveland Browns,8.5,1583.45094092808,AFC,North | ||
Pittsburgh Steelers,8.5,1578.09198940955,AFC,North | ||
Jacksonville Jaguars,9.5,1600.18698304192,AFC,South | ||
Tennessee Titans,7.5,1508.80023011146,AFC,South | ||
Indianapolis Colts,6.5,1459.76229611732,AFC,South | ||
Houston Texans,5.5,1418.28381122239,AFC,South | ||
Kansas City Chiefs,11.5,1762.52920677914,AFC,West | ||
Los Angeles Chargers,9.5,1669.57049071911,AFC,West | ||
Denver Broncos,8.5,1622.57658498554,AFC,West | ||
Las Vegas Raiders,7.5,1587.92769328906,AFC,West | ||
Philadelphia Eagles,10.5,1723.06689610956,NFC,East | ||
Dallas Cowboys,9.5,1680.12941645968,NFC,East | ||
New York Giants,8.5,1637.72667821245,NFC,East | ||
Washington Commanders,7.5,1596.99857761264,NFC,East | ||
Detroit Lions,9,1611.00993684181,NFC,North | ||
Minnesota Vikings,8.5,1607.42736606408,NFC,North | ||
Green Bay Packers,7.5,1549.21345906024,NFC,North | ||
Chicago Bears,7.5,1542.57634273391,NFC,North | ||
New Orleans Saints,9.5,1579.94137763577,NFC,South | ||
Carolina Panthers,7.5,1512.12835006181,NFC,South | ||
Atlanta Falcons,7.5,1501.03922942317,NFC,South | ||
Tampa Bay Buccaneers,6.5,1482.0264000382,NFC,South | ||
San Francisco 49ers,11.5,1730.12289472661,NFC,West | ||
Seattle Seahawks,8.5,1607.65690082201,NFC,West | ||
Los Angeles Rams,7.5,1566.85345285444,NFC,West | ||
Arizona Cardinals,5.5,1478.71549244838,NFC,West |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/latest_results.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
SELECT | ||
(_smart_source_lineno - 1)::int AS game_id, | ||
team1 AS home_team, | ||
score1 AS home_team_score, | ||
team2 AS visiting_team, | ||
score2 AS visiting_team_score, | ||
date, | ||
CASE | ||
WHEN score1 > score2 THEN team1 | ||
ELSE team2 | ||
END AS winning_team, | ||
CASE | ||
WHEN score1 > score2 THEN team2 | ||
ELSE team1 | ||
END AS losing_team, | ||
True AS include_actuals | ||
FROM "mdsbox"."main"."prep_nba_elo_latest" | ||
WHERE score1 IS NOT NULL | ||
-- remove actual results so that we can sim 2023-24 season | ||
AND 1 = 0 | ||
GROUP BY ALL |
13 changes: 13 additions & 0 deletions
13
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/post_season_schedule.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
SELECT | ||
S.key::int AS game_id, | ||
S.type, | ||
S.series_id, | ||
NULL AS visiting_conf, | ||
S.visitorneutral AS visiting_team, | ||
NULL AS visiting_team_elo_rating, | ||
NULL AS home_conf, | ||
S.homeneutral AS home_team, | ||
NULL AS home_team_elo_rating | ||
FROM "mdsbox"."main"."prep_schedule" AS S | ||
WHERE S.type <> 'reg_season' | ||
GROUP BY ALL |
9 changes: 9 additions & 0 deletions
9
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/random_num_gen.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
SELECT | ||
i.scenario_id, | ||
S.game_id, | ||
(random() * 10000)::smallint AS rand_result, | ||
0 AS sim_start_game_id | ||
FROM "mdsbox"."main"."scenario_gen" AS i | ||
CROSS JOIN "mdsbox"."main"."schedules" AS S |
13 changes: 13 additions & 0 deletions
13
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/ratings.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
SELECT | ||
orig.team, | ||
orig.team_long, | ||
orig.conf, | ||
CASE | ||
WHEN latest.latest_ratings = true AND latest.elo_rating IS NOT NULL THEN latest.elo_rating | ||
ELSE orig.elo_rating | ||
END AS elo_rating, | ||
orig.elo_rating AS original_rating, | ||
orig.win_total | ||
FROM "mdsbox"."main"."prep_team_ratings" orig | ||
LEFT JOIN "mdsbox"."main"."prep_elo_post" latest ON latest.team = orig.team | ||
GROUP BY ALL |
14 changes: 14 additions & 0 deletions
14
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/reg_season_schedule.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
SELECT | ||
(S._smart_source_lineno - 1)::int AS game_id, | ||
'reg_season' AS type, | ||
0 as series_id, | ||
V.conf AS visiting_conf, | ||
V.team AS visiting_team, | ||
V.elo_rating::int AS visiting_team_elo_rating, | ||
H.conf AS home_conf, | ||
H.team AS home_team, | ||
H.elo_rating::int AS home_team_elo_rating | ||
FROM "mdsbox"."main"."prep_nba_elo_latest" AS S | ||
LEFT JOIN "mdsbox"."main"."ratings" V ON V.team = S.team2 | ||
LEFT JOIN "mdsbox"."main"."ratings" H ON H.team = S.team1 | ||
GROUP BY ALL |
2 changes: 2 additions & 0 deletions
2
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/scenario_gen.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SELECT I.generate_series AS scenario_id | ||
FROM generate_series(1, 10000 ) AS I |
7 changes: 7 additions & 0 deletions
7
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/schedules.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SELECT | ||
* | ||
FROM "mdsbox"."main"."reg_season_schedule" | ||
UNION ALL | ||
SELECT | ||
* | ||
FROM "mdsbox"."main"."post_season_schedule" |
7 changes: 7 additions & 0 deletions
7
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/teams.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SELECT | ||
S.visitorneutral AS team_long, | ||
R.team | ||
FROM "mdsbox"."main"."prep_schedule" S | ||
LEFT JOIN "mdsbox"."main"."ratings" AS R ON R.team_long = S.visitorneutral | ||
WHERE R.team IS NOT NULL | ||
GROUP BY ALL |
5 changes: 5 additions & 0 deletions
5
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/vegas_wins.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT | ||
team, | ||
win_total | ||
FROM "mdsbox"."main"."ratings" | ||
GROUP BY ALL |
4 changes: 4 additions & 0 deletions
4
docs/compiled/nba_monte_carlo/models/nba/conformed/inputs/xf_series_to_seed.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT | ||
series_id, | ||
seed | ||
FROM "mdsbox"."main"."prep_xf_series_to_seed" |
21 changes: 21 additions & 0 deletions
21
docs/compiled/nba_monte_carlo/models/nba/conformed/playin/playin_sim_r1.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
SELECT | ||
R.scenario_id, | ||
S.game_id, | ||
EV.conf AS conf, | ||
EV.winning_team AS visiting_team, | ||
EV.elo_rating AS visiting_team_elo_rating, | ||
EH.winning_team AS home_team, | ||
EH.elo_rating AS home_team_elo_rating, | ||
-- removing the 70 point adjustment for home team advantage for now | ||
( 1 - (1 / (10 ^ (-( EV.elo_rating - EH.elo_rating - 0)::real/400)+1))) * 10000 AS home_team_win_probability, | ||
R.rand_result, | ||
CASE | ||
WHEN -- removing the 70 point adjustment for home team advantage for now | ||
( 1 - (1 / (10 ^ (-( EV.elo_rating - EH.elo_rating - 0)::real/400)+1))) * 10000 >= R.rand_result THEN EH.winning_team | ||
ELSE EV.winning_team | ||
END AS winning_team | ||
FROM "mdsbox"."main"."schedules" S | ||
LEFT JOIN "mdsbox"."main"."random_num_gen" R ON R.game_id = S.game_id | ||
LEFT JOIN "mdsbox"."main"."reg_season_end" EH ON S.home_team = EH.seed AND R.scenario_id = EH.scenario_id | ||
LEFT JOIN "mdsbox"."main"."reg_season_end" EV ON S.visiting_team = EV.seed AND R.scenario_id = EV.scenario_id | ||
WHERE S.type = 'playin_r1' |
32 changes: 32 additions & 0 deletions
32
docs/compiled/nba_monte_carlo/models/nba/conformed/playin/playin_sim_r1_end.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
WITH cte_playin_details AS ( | ||
SELECT | ||
S.scenario_id, | ||
S.game_id, | ||
S.winning_team, | ||
CASE | ||
WHEN S.winning_team = S.home_team THEN S.home_team_elo_rating | ||
ELSE S.visiting_team_elo_rating | ||
END AS winning_team_elo_rating, | ||
S.conf AS conf, | ||
CASE | ||
WHEN S.winning_team = S.home_team THEN S.visiting_team | ||
ELSE S.home_team | ||
END AS losing_team, | ||
CASE | ||
WHEN S.winning_team = S.home_team THEN S.visiting_team_elo_rating | ||
ELSE S.home_team_elo_rating | ||
END AS losing_team_elo_rating, | ||
CASE | ||
WHEN S.game_id IN (1231, 1234) THEN 'winner advance' | ||
WHEN S.game_id IN (1232, 1235) THEN 'loser eliminated' | ||
END AS result | ||
FROM "mdsbox"."main"."playin_sim_r1" S | ||
) | ||
|
||
SELECT | ||
*, | ||
CASE | ||
WHEN game_id IN (1231, 1234) THEN losing_team | ||
WHEN game_id IN (1232, 1235) THEN winning_team | ||
END AS remaining_team | ||
FROM cte_playin_details |
23 changes: 23 additions & 0 deletions
23
docs/compiled/nba_monte_carlo/models/nba/conformed/playin/playin_sim_r2.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
SELECT | ||
R.scenario_id, | ||
S.game_id, | ||
S.home_team[7:] AS home_team_id, | ||
S.visiting_team[8:] AS visiting_team_id, | ||
EV.conf AS conf, | ||
EV.remaining_team AS visiting_team, | ||
EV.winning_team_elo_rating AS visiting_team_elo_rating, | ||
EH.remaining_team AS home_team, | ||
EH.losing_team_elo_rating AS home_team_elo_rating, | ||
-- removing the 70 point adjustment for home team advantage for now | ||
( 1 - (1 / (10 ^ (-( EV.winning_team_elo_rating - EH.losing_team_elo_rating - 0)::real/400)+1))) * 10000 as home_team_win_probability, | ||
R.rand_result, | ||
CASE | ||
WHEN -- removing the 70 point adjustment for home team advantage for now | ||
( 1 - (1 / (10 ^ (-( EV.winning_team_elo_rating - EH.losing_team_elo_rating - 0)::real/400)+1))) * 10000 >= R.rand_result THEN EH.remaining_team | ||
ELSE EV.remaining_team | ||
END AS winning_team | ||
FROM "mdsbox"."main"."schedules" S | ||
LEFT JOIN "mdsbox"."main"."random_num_gen" R ON R.game_id = S.game_id | ||
LEFT JOIN "mdsbox"."main"."playin_sim_r1_end" EH ON R.scenario_id = EH.scenario_id AND EH.game_id = S.home_team[7:] | ||
LEFT JOIN "mdsbox"."main"."playin_sim_r1_end" EV ON R.scenario_id = EV.scenario_id AND EV.game_id = S.visiting_team[8:] | ||
WHERE S.type = 'playin_r2' |
19 changes: 19 additions & 0 deletions
19
docs/compiled/nba_monte_carlo/models/nba/conformed/playin/playin_sim_r2_end.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT | ||
P1.scenario_id, | ||
P1.conf, | ||
P1.winning_team, | ||
P1.conf || '-7' AS seed, | ||
P1.winning_team_elo_rating | ||
FROM "mdsbox"."main"."playin_sim_r1_end" P1 | ||
WHERE P1.result = 'winner advance' | ||
UNION ALL | ||
SELECT | ||
P2.scenario_id, | ||
P2.conf AS conf, | ||
P2.winning_team, | ||
P2.conf || '-8' AS seed, | ||
CASE | ||
WHEN P2.winning_team = P2.home_team THEN P2.home_team_elo_rating | ||
ELSE P2.visiting_team_elo_rating | ||
END AS elo_rating | ||
FROM "mdsbox"."main"."playin_sim_r2" P2 |
20 changes: 20 additions & 0 deletions
20
docs/compiled/nba_monte_carlo/models/nba/conformed/playoffs/initialize_seeding.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
|
||
WITH cte_teams AS ( | ||
SELECT | ||
scenario_id, | ||
conf, | ||
winning_team, | ||
seed, | ||
elo_rating | ||
FROM "mdsbox"."main"."reg_season_end" | ||
WHERE season_rank < 7 | ||
UNION ALL | ||
SELECT * | ||
FROM "mdsbox"."main"."playin_sim_r2_end" | ||
) | ||
|
||
SELECT | ||
T.*, | ||
0 AS sim_start_game_id | ||
FROM cte_teams T |
Oops, something went wrong.