Skip to content

Commit

Permalink
misc cleanup (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
matsonj committed Dec 27, 2023
1 parent 894f0fb commit e509345
Show file tree
Hide file tree
Showing 19 changed files with 73,500 additions and 73,513 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"L016",
"L031",
"L034"
]
],
"files.autoSave": "off"
}
3 changes: 2 additions & 1 deletion data/ncaaf/ncaaf_results.csv
Original file line number Diff line number Diff line change
Expand Up @@ -865,4 +865,5 @@ Rk,Wk,Date,Time,Day,Winner,Winner_Pts,,Loser,Loser_Pts,Notes
864,15,Dec 2 2023,8:00 PM,Sat,(2) Michigan,26,N,(18) Iowa,0,
865,15,Dec 2 2023,4:00 PM,Sat,(25) Southern Methodist,26,@,(17) Tulane,14,
866,15,Dec 2 2023,12:00 PM,Sat,(7) Texas,49,N,(19) Oklahoma State,21,
867,15,Dec 2 2023,4:00 PM,Sat,Troy,49,,Appalachian State,23,
867,15,Dec 2 2023,4:00 PM,Sat,Troy,49,,Appalachian State,23,
868,16,Dec 9 2023,3:00 PM,Sat,Army,17,N,Navy,11,
10 changes: 0 additions & 10 deletions data/ncaaf/ncaaf_schedule.csv
Original file line number Diff line number Diff line change
Expand Up @@ -856,14 +856,4 @@ id,Week,Day,Date,VisTm,HomeTm,Neut
855,14,Nov 25 2023,Sat,Western Kentucky,Florida International,N
856,14,Nov 25 2023,Sat,Wisconsin,Minnesota,N
857,14,Nov 25 2023,Sat,Wyoming,Nevada,N
858,15,Dec 1 2023,Fri,New Mexico State,Liberty,N
859,15,Dec 1 2023,Fri,Washington,Oregon,Y
860,15,Dec 2 2023,Sat,Appalachian State,Troy,N
861,15,Dec 2 2023,Sat,Boise State,Nevada-Las Vegas,N
862,15,Dec 2 2023,Sat,Alabama,Georgia,Y
863,15,Dec 2 2023,Sat,Florida State,Louisville,Y
864,15,Dec 2 2023,Sat,Toledo,Miami (FL),N
865,15,Dec 2 2023,Sat,Iowa,Michigan,Y
866,15,Dec 2 2023,Sat,Texas,Oklahoma State,Y
867,15,Dec 2 2023,Sat,Southern Methodist,Tulane,N
868,16,Dec 9 2023,Sat,Navy,Army,Y
2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

40 changes: 19 additions & 21 deletions evidence/pages/nba/historical_matchups.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
```sql elo_history
select *
from nba_elo_history.nba_elo
where playoff is null
```

```sql seasons
Expand Down Expand Up @@ -109,14 +108,14 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
select
key,
count(*) as ct,
count(*) filter (where winner = '${inputs.team1}' and playoff is null) as wins,
count(*) filter (where loser = '${inputs.team1}' and playoff is null) as losses,
count(*) filter (where winner = '${inputs.team1}' and team1 = '${inputs.team1}' and playoff is null) as home_wins,
count(*) filter (where loser = '${inputs.team1}' and team1 = '${inputs.team1}' and playoff is null) as home_losses,
count(*) filter (where winner = '${inputs.team1}' and team2 = '${inputs.team1}' and playoff is null) as away_wins,
count(*) filter (where loser = '${inputs.team1}' and team2 = '${inputs.team1}' and playoff is null) as away_losses,
count(*) filter (where winner = '${inputs.team1}' and playoff is not null) as playoff_wins,
count(*) filter (where loser = '${inputs.team1}' and playoff is not null) as playoff_losses,
count(*) filter (where winner = '${inputs.team1}' and playoff = 'r') as wins,
count(*) filter (where loser = '${inputs.team1}' and playoff = 'r') as losses,
count(*) filter (where winner = '${inputs.team1}' and team1 = '${inputs.team1}' and playoff = 'r') as home_wins,
count(*) filter (where loser = '${inputs.team1}' and team1 = '${inputs.team1}' and playoff = 'r') as home_losses,
count(*) filter (where winner = '${inputs.team1}' and team2 = '${inputs.team1}' and playoff = 'r') as away_wins,
count(*) filter (where loser = '${inputs.team1}' and team2 = '${inputs.team1}' and playoff = 'r') as away_losses,
count(*) filter (where winner = '${inputs.team1}' and playoff <> 'r') as playoff_wins,
count(*) filter (where loser = '${inputs.team1}' and playoff <> 'r') as playoff_losses,
avg(pf) as pf,
avg(pa) as pa,
avg(pf) - avg(pa) as margin,
Expand Down Expand Up @@ -148,14 +147,14 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
select
key,
count(*) as ct,
count(*) filter (where winner = '${inputs.team2}' and playoff is null) as wins,
count(*) filter (where loser = '${inputs.team2}' and playoff is null) as losses,
count(*) filter (where winner = '${inputs.team2}' and team1 = '${inputs.team2}' and playoff is null) as home_wins,
count(*) filter (where loser = '${inputs.team2}' and team1 = '${inputs.team2}' and playoff is null) as home_losses,
count(*) filter (where winner = '${inputs.team2}' and team2 = '${inputs.team2}' and playoff is null) as away_wins,
count(*) filter (where loser = '${inputs.team2}' and team2 = '${inputs.team2}' and playoff is null) as away_losses,
count(*) filter (where winner = '${inputs.team2}' and playoff is not null) as playoff_wins,
count(*) filter (where loser = '${inputs.team2}' and playoff is not null) as playoff_losses,
count(*) filter (where winner = '${inputs.team2}' and playoff = 'r') as wins,
count(*) filter (where loser = '${inputs.team2}' and playoff = 'r') as losses,
count(*) filter (where winner = '${inputs.team2}' and team1 = '${inputs.team2}' and playoff = 'r') as home_wins,
count(*) filter (where loser = '${inputs.team2}' and team1 = '${inputs.team2}' and playoff = 'r') as home_losses,
count(*) filter (where winner = '${inputs.team2}' and team2 = '${inputs.team2}' and playoff = 'r') as away_wins,
count(*) filter (where loser = '${inputs.team2}' and team2 = '${inputs.team2}' and playoff = 'r') as away_losses,
count(*) filter (where winner = '${inputs.team2}' and playoff <> 'r') as playoff_wins,
count(*) filter (where loser = '${inputs.team2}' and playoff <> 'r') as playoff_losses,
avg(pf) as pf,
avg(pa) as pa,
avg(pf) - avg(pa) as margin,
Expand Down Expand Up @@ -253,9 +252,7 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!

<script>

$: test_val = Math.min(
combined_trend.map(item => item.elo_rating)
)
$: y_min = Math.min(...combined_trend.map(item => item.elo))

</script>

Expand All @@ -265,7 +262,8 @@ Ever wondered if the '86 Celtics could beat the '96 Bulls? Wonder no more!
y=elo
title='elo change over time'
series=team
yMin={parseFloat(test_val)-25}
yMin={parseFloat(y_min)-25}
xAxisTitle='games played'
handleMissing=connect
colorPalette={
[
Expand Down
20 changes: 4 additions & 16 deletions evidence/pages/nba/in-season tournament/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ ORDER BY conf, wins DESC, made_tournament_pct1 DESC, margin DESC

# NBA In-season Tournament

New for the 2023-2024 season, the NBA has introduced an In-Season Tournament. The tournament consists of Group Play followed by single elimination knock out rounds. You can learn about it [here](https://www.nba.com/news/in-season-tournament-101).
Congrats to the Los Angeles Lakers for winning the 2023-24 NBA In-Season Tournament!

_New for the 2023-2024 season, the NBA has introduced an In-Season Tournament. The tournament consists of Group Play followed by single elimination knock out rounds. You can learn about it [here](https://www.nba.com/news/in-season-tournament-101)._

## Standings

Expand Down Expand Up @@ -157,25 +159,11 @@ New for the 2023-2024 season, the NBA has introduced an In-Season Tournament. Th

## Recent Games

<DataTable data={most_recent_games.filter(d => d.type === "tournament")} rows=5>
<DataTable data={most_recent_games.filter(d => d.type === "tournament" || d.type === 'knockout')} rows=5>
<Column id=date/>
<Column id=visiting_team/>
<Column id=" "/>
<Column id=home_team/>
<Column id=winning_team/>
<Column id=score/>
</DataTable>

## Upcoming Games

<DataTable data={future_games.filter(d => d.type === "tournament" | d.type === "knockout" )} >
<Column id=game_id/>
<Column id=visitor/>
<Column id=visitor_ELO title="Elo Rtg"/>
<Column id=home/>
<Column id=home_ELO title="Elo Rtg"/>
<Column id=home_win_pct1 title="Win % (Home)"/>
<Column id=american_odds align=right title="Odds (Home)"/>
<Column id=implied_line_num1 title="Line (Home)"/>
<Column id=predicted_score title="Score"/>
</DataTable>
51 changes: 13 additions & 38 deletions evidence/pages/nba/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ queries:
- future_games: nba/future_games.sql
---

```sql teams
select * from src_nba_teams
order by team
```

```sql filtered_future_games
select *
from ${future_games}
where home like '${inputs.home_team}'
where home like '${inputs.team}' OR visitor like '${inputs.team}'
```

# NBA Monte Carlo Simulator
Expand All @@ -25,58 +30,25 @@ This data was last updated as of <Value data={thru_date} column=end_date/>.
## [Upcoming Games](/nba/predictions)

<Dropdown
data={future_games}
name=home_team
value=home
data={teams}
name=team
value=team
title="Select a Team"
>
<DropdownOption valueLabel="All Teams" value="%" />
</Dropdown>
<DataTable data={filtered_future_games} rows=5 link=game_link>
<Column id=game_id/>
<Column id=date/>
<Column id=T title=" "/>
<Column id=visitor/>
<Column id=visitor_ELO title="Elo Rtg"/>
<Column id=home/>
<Column id=home_ELO title="Elo Rtg"/>
<Column id=home_win_pct1 title="Win % (Home)"/>
<Column id=american_odds align=right title="Odds (Home)"/>
<Column id=implied_line_num1 title="Line (Home)"/>
<Column id=predicted_score title="Score"/>
</DataTable>

## [In-Season Tournament](/nba/in-season%20tournament)

<Tabs>
<Tab label="East">

### Predicted Seeding - Knockout Round

<DataTable data={tournament_seeding.filter(d => d.conf === "East")} rows=15>
<Column id=team/>
<Column id="1_pct1" contentType=colorscale colorMax=1/>
<Column id="2_pct1" contentType=colorscale colorMax=1/>
<Column id="3_pct1" contentType=colorscale colorMax=1/>
<Column id="4_pct1" contentType=colorscale colorMax=1/>
<Column id="total_pct1" contentType=colorscale colorMax=1/>
</DataTable>
</Tab>
<Tab label="West">

### Predicted Seeding - Knockout Round

<DataTable data={tournament_seeding.filter(d => d.conf === "West")} rows=15>
<Column id=team/>
<Column id="1_pct1" contentType=colorscale colorMax=1/>
<Column id="2_pct1" contentType=colorscale colorMax=1/>
<Column id="3_pct1" contentType=colorscale colorMax=1/>
<Column id="4_pct1" contentType=colorscale colorMax=1/>
<Column id="total_pct1" contentType=colorscale colorMax=1/>
</DataTable>
</Tab>
</Tabs>

## [Team Standings](/nba/teams)

<DataTable data={summary_by_team} link=team_link rows=5 search=true>
Expand All @@ -85,6 +57,9 @@ This data was last updated as of <Value data={thru_date} column=end_date/>.
<Column id=record/>
<Column id=elo_rating/>
<Column id=avg_wins/>
<Column id=elo_vs_vegas_num1 contentType=delta/>
<Column id=make_playoffs_pct1/>
<Column id=win_finals_pct1/>
</DataTable>

## Conference Summaries
Expand Down
105 changes: 59 additions & 46 deletions evidence/pages/nba/predictions/[nba_games].md
Original file line number Diff line number Diff line change
Expand Up @@ -41,50 +41,60 @@ GROUP BY ALL
```

```predictions_table
WITH cte_visitor_elo AS (
SELECT
'Away Elo Rating' as type,
game_id,
visitor_ELO as value
FROM ${future_games}
),
cte_home_elo AS (
SELECT
'Home Elo Rating',
game_id,
home_ELO
FROM ${future_games}
),
cte_elo_diff AS (
SELECT
'Elo Difference',
game_id,
elo_diff
FROM ${future_games}
),
cte_hfa AS (
SELECT
'Home Court Advantage',
game_id,
70 as hfa
FROM ${future_games}
),
cte_elo_diff_hfa AS (
SELECT
'Total Difference',
game_id,
elo_diff_hfa
FROM ${future_games}
)
SELECT * FROM cte_visitor_elo
UNION ALL
SELECT * FROM cte_home_elo
UNION ALL
SELECT * FROM cte_elo_diff
UNION ALL
SELECT * FROM cte_hfa
UNION ALL
SELECT * FROM cte_elo_diff_hfa
WITH cte_visitor_elo AS (
SELECT
'Away Elo Rating' as type,
game_id,
visitor_ELO as value,
1 as key
FROM ${future_games}
),
cte_home_elo AS (
SELECT
'Home Elo Rating',
game_id,
home_ELO,
2
FROM ${future_games}
),
cte_elo_diff AS (
SELECT
'Elo Difference',
game_id,
elo_diff,
3
FROM ${future_games}
),
cte_hfa AS (
SELECT
'Home Court Advantage',
game_id,
70 as hfa,
4
FROM ${future_games}
),
cte_elo_diff_hfa AS (
SELECT
'Total Difference',
game_id,
elo_diff_hfa,
5
FROM ${future_games}
),
cte_unions AS (
SELECT * FROM cte_visitor_elo
UNION ALL
SELECT * FROM cte_home_elo
UNION ALL
SELECT * FROM cte_elo_diff
UNION ALL
SELECT * FROM cte_hfa
UNION ALL
SELECT * FROM cte_elo_diff_hfa
)
select Type, Value, Key, game_id from cte_unions
GROUP BY ALL
ORDER BY key
```

```sql filtered_future_games
Expand Down Expand Up @@ -159,6 +169,7 @@ Diff. of <Value data={future_games.filter(d => d.game_id === parseInt(params.nba
fg.game_id === parseInt($page.params.nba_games, 10) && (fg.home == gt.team || fg.visitor == gt.team))
).map(item => item.elo_rating)
)
$: y_min = Math.min(1600,test_val)

</script>

Expand All @@ -171,15 +182,17 @@ Diff. of <Value data={future_games.filter(d => d.game_id === parseInt(params.nba
y=elo_post
title='elo change over time'
series=team
yMin={parseFloat(test_val)-10}
yMin={parseFloat(y_min)-10}
handleMissing=connect
colorPalette={
[
'#29BDAD',
'#DE4500'
]
}
/>
>
<ReferenceLine y=1600 label="league avg." hideValue=true labelPosition=aboveStart />
</LineChart>
## Last 5 Games - <Value data={summary_by_team.filter(st => future_games.some(fg => fg.game_id === parseInt(params.nba_games, 10) && (fg.visitor == st.team)))} column=team/>

Expand Down
Loading

0 comments on commit e509345

Please sign in to comment.