Fanalyticsports | Talk on the Customer 360 View Applied to the Sporting World

We've arrived in Stevens Point to speak at the Great Lakes Analytics in Sports Conference. With over 70 speakers from around the world and some people doing some really cool things in Sports Analytics it's an exciting time. 

Feel free to check out the list of speakers and topics; including ourselves and listen in to our live session @ 1:30 today. 

https://www.uwsp.edu/cols/Pages/GLASC/analyticsconference.aspx

Here is the Facebook live link.

https://www.facebook.com/analyticsconference/

 

Fanalyticsports | Vote for Us in the IronViz

If you've followed our recent IronViz post,  where we detailed out how we used data science and Tableau to look at "The Journey To The Tourney" then we'd love for you to vote for us. We are glad to have made the initial cut as one of sixty in this nationwide competition. Click the link below to see the competition and vote for us or use the hashtag #GeoIronVizsgerou on twitter to vote. 

https://public.tableau.com/en-us/s/time-to-vote-iron-viz-geospatial

There are some pretty cool visualizations but we are one of the few to have used a variety of processes and tools to create a pretty cool story. Best of luck and thanks for voting. 

Fanalyticsports | Iron Viz 2017

Check out our entry for the Iron Viz competition and up vote if you like it. Our goal was to design something that looked at the proximity of opponents in the NCAA Final Four as part of our #AnalyticsRoadToTheFinalFour. It's a combination of a variety of Business Intelligence tools & solutions from AWS, Python, R, Atom, GeoJSon, and Tableau. All positioned in one dashboard to see how your team have seeded and traveled throughout the years. Feel free to check out your team and enjoy. 
 

Below is a quick piece on the steps used to complete the project. 

Step 1: Data Gathering

We used a combination of sources for this from http://www.sports-reference.com/cbb to API calls from Sportsradar. For more information on this API follow our upcoming blog on this but below is a basic call to grab the teams and loop through each team to gather the information. There is some pretty cool data in these feeds

##Python Script
import csv as csv 
import numpy as np

# Open up the csv file in to a Python object
csv_file_object = csv.reader(open('/Users/name/Desktop/NCAA_TEAMS_UPLOAD.csv', 'rb')) 
header = csv_file_object.next()  # The next() command just skips the 
                                 # first line which is a header
data=[]                          # Create a variable called 'data'.
for row in csv_file_object:      # Run through each row in the csvfile,
    data.append(row)             # adding each row to the data variable
ncaa_team_data = np.array(data) # Then convert from a list to an array
               # Be aware that each item is currently
               # a string in this format
##Loop through teams and gets stats using API               
import urllib2
import pandas as pd

##Use results and put them in a dataset to be used for looping through play by play data
raw_data_list = []

for rows in ncaa_team_data:
    url = "http://api.sportradar.us/ncaamb-t3/seasontd/2016/REG/teams/"+rows[2]+'/'"statistics.json?api_key=#"
    try:
        raw_data = urllib2.urlopen(url).read()
        if raw_data != "":
            raw_data_list.append(raw_data)
    except:
        pass

data = "[" + (",".join(raw_data_list)) + "]"
data = pd.read_json(data, orient='records')
data

Step 2: Data Wrangling & Geocoding

For this we switched to R to use it's geolocation packaging. With the game and the following data points: Home_City_State, Away_City_State, and Stadium_City_State we calculate the distance as a crow flies for each game. 

## R Script
## Select the file from the file chooser
fileToLoad <- file.choose(new = TRUE)
## Read in the CSV data and store it in a variable 
origAddress <- read.csv(fileToLoad, stringsAsFactors = FALSE)
## View Table 
View(origAddress)
##Library GGMAP 
library(ggmap)
## Initialize the data frame
geocoded <- data.frame(stringsAsFactors = FALSE)
# Loop through the addresses to get the latitude and longitude of each address and add it to the
# origAddress data frame in new columns lat and lon
# Stadium
for(i in 1:nrow(origAddress))
{
  # Print("Working...")
  result <- geocode(origAddress$Stadium_City_State[i], output = "latlona", source = "google")
  origAddress$lon[i] <- as.numeric(result[1])
  origAddress$lat[i] <- as.numeric(result[2])
  origAddress$geoAddress[i] <- as.character(result[3])
}
## View Table 
View(origAddress)
# Loop through the addresses to get the latitude and longitude of each address and add it to the
# origAddress data frame in new columns lat and lon
# Home Team 
for(i in 1:nrow(origAddress))
{
  # Print("Working...")
  result <- geocode(origAddress$Home_City_State[i], output = "latlona", source = "google")
  origAddress$lon_ht[i] <- as.numeric(result[1])
  origAddress$lat_ht[i] <- as.numeric(result[2])
  origAddress$geoAddress_ht[i] <- as.character(result[3])
}
##View Table 
##View(origAddress)
# Loop through the addresses to get the latitude and longitude of each address and add it to the
# origAddress data frame in new columns lat and lon
# Away Team 
for(i in 1:nrow(origAddress))
{
  # Print("Working...")
  result <- geocode(origAddress$Away_City_State[i], output = "latlona", source = "google")
  origAddress$lon_at[i] <- as.numeric(result[1])
  origAddress$lat_at[i] <- as.numeric(result[2])
  origAddress$geoAddress_ht[i] <- as.character(result[3])
}
## View Table 
View(origAddress)
## Get Distance Between Coordiantes
##devtools::install_github("tidyverse/magrittr")
##install.packages("dplyr")
library(magrittr)
library(dplyr)
origAddress %>% head()
## Get Home Distance from Center
hdistanceFromStadium = by(origAddress, 1:nrow(origAddress), function(row) { distHaversine(c(row$lon_ht, row$lat_ht), c(row$lon, row$lat))  })
## Get Away Distance from Center
adistanceFromStadium = by(origAddress, 1:nrow(origAddress), function(row) { distHaversine(c(row$lon_at, row$lat_at), c(row$lon, row$lat))  })
## Add in hdistance and adistance 
hout = mutate(origAddress, hdistanceFromStadium)
finalout = mutate(hout, adistanceFromStadium)
##Write to a CSV Out File 
# Write a CSV file to working directory
##write.csv(finalout, "geocoded_ncaa_distance.csv")
write.csv(finalout, "/Users/name/desktop/geocode_ncaa_distance_14_17.csv")

Step 3: Create Visualization Using Data and Spatial File

Geojson

We start with creating a geojson spatial file which Tableau can incorporate. This is my first time using geojson so I was glad I found http://geojson.io to help create my location map. I used my cvs to create the json copied this into Atom. Formatted as a .geojson and within minutes I had my first .geojson file. 

With that complete we moved on to uploading the spatial file and the NCAA location team data to begin developing our Viz.

This part was pretty easy with some suggestions and tips from a few other Viz experts we were able to use the cool new pathing feature in 10 and bring across the logos. The spatial file became a nice to have but with the logos and everything else all we really needed was the city points which become the stadiums on the map.

Through in a few basic scatter charts and some action items and the dashboard is nice interactive way to travel the Final Four and follow your team and the effect distance had on them. 

Enjoy. 

Fanalyticsports | Journey to the Tourney #AnalyticsRoadToTheFinalFour

It's Fanalyticsports Friday so come check out our Viz on the Journey to the Tourney. View your team and the path they took using the 2014-2016 NCAA Tournament results and pairings. We'll be making a few tweaks to this Viz as we proceed and will create a step by step walk through once complete. But for now check out how your team did and analyze how distance plays a role in the Tourney. (If you've never used Tableau before, do yourself a favor and check it) 

This project started out by trying to determine the role traveling distances played in selecting/playing in the NCAA Tournament. What we found is that from 2014-2016 67% of the time the closet team wins their first round matchup, which peaked in 2014 at 69%. Breaking this out further by seeding, the top 3 seeds definitely showcase geographic proximity to home and a stronger winning percentage. Between 2014-2016 teams have traveled somewhere between 81 to 2,887 mile just for their game. (Average mileage per team) This is a huge disparity and may be reflective of the strength of college basketball teams in general and their location.

Further we looked into mapping the distance to give you a good view of how far teams have traveled and how the closer team may have an advantage. (I guess that is why Michigan State lost last year. Look how much closer Middle Tennessee is to the venue.) 

From what we've seen the top 3 seeds have a geographic advantage compared to everyone else during Selection Sunday and judging by the distances traveled and the geographic placement of teams there may be room for improvement as regionality appears to play a smaller role than we thought and may hold an advantage to winning. 

Fanalyticsports | Proximity & The Final Four

For those of you out there that are wondering what we do here, this is a cool concept we developed to showcase Proximity and The Final Four. Our initial thought was that the teams that are closer to the arena they play in are more likely to win. As their fans can travel better and it seems more like a home game for them. While that was the initial analysis as we dove deeper into this it looked like there was a geographical component as well a host of other things to analyze. Below is a quick look at how we are tackling this project. We'll be posting a more thorough blog with code and links soon. As always we are open to suggestions along the way. 

 

Proximity & The Final Four

Data- http://www.sports-reference.com, Google's API for geocoding 

R- For looping through each record to gather the coordinate and distance from the stadium using the as the crow flies technique. (Could also use Python but wanted to use R as it's been awhile since I've been in this tool again.) 

Tableau Public- For Visualization and interaction with the data. Pathing technique for flight like interaction and summary stats around the teams and seeds. 

 

 

 

 

 

 

 

Fanalyticsports | Networking

Today was a day of networking and driving the sales pitch. We are always looking to meet and network with people and see what synergies exist. I've been lucky enough to have made some great friends along the way who have helped me make some great connections. (In fairness the majority of these people have an MSU connection. What can I say Sparty travels well and is well liked.) Today's quest brought us in front of the Milwaukee Bucks with the hopes of trying to find work for us down the road. First impressions were good but this is an incredibly hard field to get into and in fairness we are a new company who has one small contract; I was just happy to meet with them and see what they were doing. We'll see where it takes us but for now we'll enjoy watching tonight's game and for those of you following our #AnalyticsRoadToThe FinalFour we are finalizing a blog that walks you through what we did and will allow you to see how your team looks as long as your not an Ohio State fan.  

Fanalyticsports | What We Do

Thanks for joining us back on Our Journey and feel free to reach out to us with any questions along the way. We also have a mailing list that you can join for key updates and news located on our website at (www.fanalyticsports.com) or follow us on Twitter @fanalyticsports

So what do we do?

With all the buzzwords around the business intelligence and analytics community (See the simple Word Cloud Below) we understand that it can be confusing.

This world can contain advanced mathematics, coding, lots and lots of data, and a tremendous amount of changing technology. But the best way to describe what we do is to simply say we develop, design, and implement business solutions for the sporting world. Whether that is combining and analyzing ticket data, social data, concession data, and other data; or predicting what might happen next; or even developing a real-time dashboard/application that provides you with the shortest wait time in line. We aim to deliver insightful solutions that eliminate the black box confusion surrounding the profession. 

Throughout our career we've learned from some of the nation's best on how to provide insights and analysis and we are passionate about continuous learning. That being said, still what is it that we do? For us the best way is to show you. I've always been accustomed to leading by doing and this would be no different. With that in mind we've developed the #AnalyticsRoadToTheFinalFour as an exciting and legal way (not disclosing trade secrets) to show you how we connect the dots in the business intelligence and analytics profession. 

Our first demo application looks at how distance and proximity plays a role in the NCAA Final Four. Below is a quick look at an interactive application we are developing to showcase this. Stay tuned for more to come. (Don't worry if you are not a Spartan fan like I am, you will be able to see your favorite team as well.) 

Stay tuned for more 

Fanalyticsports | The Journey

After two years of hard work we are proud to launch Fanalyticsports. A sports consulting company focussing on BI solutions and socializing the data driven approach to sports. We have had a lot of help along the way and would like to thank all of those who have helped make us who we are. 

Fanalyticsports started out like all great startups do with some lively sports banter between colleagues and friends during a Lions game (If I remember right it was the year the Lions won the Super Bowl). Later it became a reality after I received offers from two professional sports teams to run their analytics departments (My dream job). In the end family and proximity to my roots led me to remain in my current location (atleast for now); however what I realized was that my skills translated well to this environment and there was a big gap between providing BI and Analytics to the sporting world primarily on the business side. 

In 2017 we signed our first contract and we are working on developing another project the #AnalyticsRoadToTheFinalFour which you'll see throughout March showcasing our talents across a plethora of platforms in order to drive decision on the NCAA Final Four. 

Stay tuned for more and you can track Our Journey below.......