Enrollment Nerdery

A place to collect my thoughts on data analysis within Enrollment Management. Dare I call it Enrollment Science?

Where you can find me

NHL Play-by-Play Viewer using R Shiny

This repo contains my first-ever R Shiny project. It’s simple, and represents a minimally viable app. It’s super basic, but the app allows us to query and visualize the NHL’s Play-by-play event logs for a given game.

I updated the app for the 2015-16 season. There are a few manual updates to the code that I could refactor and allow the end-user to set, but in the short run, it works.

The app also leverages a simple shot probability model that I built.

That repo can be found here.

Run the app locally

  1. If you haven’t already, install R here for your OS.
  2. Open up a terminal, and type R
  3. When R opens, type, install.packages('shiny') into the command line
  4. Assuming that runs without error, run my app by typing shiny::runGitHub("nhl-shiny", "btibert3")

This should fire up your default modern browser. It will take a few moments to load the data, and will refresh every 20 seconds or so. When you want to quit the app, go back to the terminal and type CONTROL-C to kill the process.

A quick screenshot

Clearly this is very unpolished, but just a quick highlight of the dashboard app.



About the Shot Prediction Model

In my previous repo, I highlight a very proof-of-concept model. It’s not elegant, but very effective when estimating a player’s total season goals. With respect to the point estimates (actual probability of a shot going in), it has some room for improvement; AUC is mid .7’s.

The approach I use is simple: fit a logistic regression to predict a given shot going in goal given:

When applying the model to every shot from a player (identified by the NHL playerid), and correlating the actual versus predicted goals over the course of a season, the R-squared is a touch under .9.


comments powered by Disqus