Skip to content

Instantly share code, notes, and snippets.

View HavocAnalytics's full-sized avatar
🏒

Michael Ellison HavocAnalytics

🏒
  • Northern Virginia
View GitHub Profile
@bayesball
bayesball / blog_code_example.R
Created April 23, 2023 22:18
R work for Cluster Luck Scoring in 2022 Season
# read in two functions
source("generate_runs.R")
source("retro_game_work.R")
library(dplyr)
# Phillies game plays on April 16, 2023
plays <- c("HR", "1B", "BB", "BB", "1B", "OUT", "1B",
@daveklotz
daveklotz / results.txt
Created July 31, 2021 20:26
Results of Back Testing from 2021, 2018 and 2017
2021 through July 27th
======================
+-------------+-----------+----------+------------+------------+
| Certainty | NumBets | Stake | Winnings | ROI |
|-------------+-----------+----------+------------+------------|
| Pr > 0.0 | 1395 | 162761 | 1366 | 0.00839267 |
| Pr > 0.05 | 439 | 48121 | 4786 | 0.0994576 |
| Pr > 0.10 | 125 | 13991 | 1503 | 0.107426 |
| Pr > 0.15 | 64 | 7294 | 226 | 0.0309844 |
@daveklotz
daveklotz / daily-sheet-generation.py
Created July 31, 2021 19:48
Generate the data and run the ANN so I can get picks for today's games
######
# NOTE: this includes calculaiton for my first Wins Above Replacement approach, as well as the current DRA- approach
######
games = mlbgame.day(2021,7,30)
daily_game_id = 1
unique_row_id = 1. # just to make sure i have the same format as legacy spreadsheet
location_index = 0
@nntrn
nntrn / espn-api-list.md
Last active November 2, 2025 19:37
List of nfl api endpoints from espn

List of NFL API Endpoints

This page has been updated a lot in the past 3 years. Older revisions you might like more than this one:

library(tidyverse)
library(espnscrapeR)
library(gt)
all_win_rate <- scrape_espn_win_rate()
wide_win_rate <- all_win_rate %>%
pivot_wider(names_from = stat, values_from = win_pct, id_col = team) %>%
set_names(nm=c("team", "prwr", "rswr", "pbwr", "rbwr")) %>%
mutate(prwr_rk = min_rank(desc(prwr)), .before = prwr) %>%
@bayesball
bayesball / baseball_scores.R
Last active March 26, 2023 14:17
Code to download Retrosheet game log data with the focus on studying game scores.
# Main function to get Retrosheet game scores
get_scores <- function(season){
require(dplyr)
require(readr)
load_gamelog <- function(season) {
glheaders <- read_csv("https://raw.githubusercontent.com/beanumber/baseball_R/master/data/game_log_header.csv")
remote <- paste0("http://www.retrosheet.org/gamelogs/gl",
season, ".zip")
local <- paste0("gl", season, ".zip")
@btatkinson
btatkinson / td_pg_embed_R
Last active September 12, 2023 09:16
touchdown count per game in R using nflscrapR
library(tidyverse)
library(tidyr)
library(dplyr)
library(na.tools)
seasons <- seq(2014, 2019);
# iteration count
i = 0
df <- NULL;
@rdpharr
rdpharr / backtest_mlb.ipynb
Created August 2, 2019 02:16
MLB 30-day Backtest Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@guga31bb
guga31bb / nflscrapr.md
Last active August 18, 2023 07:45
Simple guide for using nflscrapR

THIS IS OUTDATED. PLEASE FOLLOW THE FOLLOWING LINK

--> A beginner's guide to nflfastR <--

Basic nflscrapR tutorial

I get a lot of questions about how to get nflscrapR up and running. This guide is intended to help new users build interesting tables or charts from the ground up, taking the raw nflscrapR data.

Quick word if you're new to programming: all of this is happening in R. Obviously, you need to install R on your computer to do any of this. Make sure you save what you're doing in a script (in R, File --> New script) so you can save your work and run multiple lines of code at once. To run code from a script, highlight what you want, right click, and select Run line. As you go through your R journey, you might get stuck and have to google a bunch of things, but that's totally okay and normal. That's how I wrote this thing!