Intro to Flask & Data Science in Sports

What is a "microframework"?

  1. Receive an HTTP request at a URL route
  2. Handle the HTTP request with a controller
  3. Return an HTTP response from that controller

"Out-of-the-box" we can only:

What's missing?

  1. Object Relational Mapper
  2. User Account Management
  3. User Authentication
  4. Database Migrations
  5. Forms 
  6. Templating Engine
  7. Security (CORS, CSRF, etc...)

Lots of important features!

So, why Flask?

"Cream of the Crop"

Independently-developed solutions rise to top...

  1. Object Relational Mapper => SQLAlchemy
  2. User Account Management => Flask-admin
  3. User Authentication => Flask-login
  4. Database Migrations => Alembic
  5. Forms => WTForms
  6. Templating Engine => Jinja2
  7. Security (CORS, CSRF, etc...) => Flask-CORS...

"Hello World"

from flask import Flask
# Instantiate our app...
app = Flask(__name__)

# We define our URL route, controller to handle requests
@app.route('/')
def hello_world():
    return '<h1>Hello World</h1>'

if __name__ == "__main__":
    app.run()
  1. Frequency of new web-dev projects == low
  2. Speed of Flask "Hello World" dev == fast

"A la Carte Extensions"

  1. flask_sqlalchemy
  2. flask_restless
  3. flask_login
  4. flask_cors
  5. flask_admin

"Blueprints"

Modularization and Encapsulation

  • Models
  • Controllers
  • Templates
  • Routes

Why not Flask?

  • Many ways to solve one problem => Poor Maintainability
  • Non-centralized Documentation ¬† => More Google Searches
  • 136k Django vs. 15k Flask Questions on SO => Smaller Community

Best Use Case:

API Services

Specifically for SPAs (single-page applications)

Data Science in Professional Sports

"Player Tracking" Timeline

  1. Sydney, Australia olympics (2000)
    • Rugby, Soccer, Catapult Technologies
  2. NBA begins using SportVU (2006)
  3. NFL begins using Zebra Technologies (2015)

Other Areas of Interest

  1. Sleep Tracking
    • Rise, Jawbone, Readiband, Whoop
  2. Nutrition and Genetics
    • Athletigen, InsideTracker
  3. Data Aggregation & Reporting Platforms
    • Kinduct (Intel's gamble)
    • Edge10 (IBM's gamble)

The other 90% of my job...

  1. Data
    • Scouting Evaluations
    • Player Physical Measurables
    • Player Stats
    • Injury History
  2. Applications
    • Data Warehousing
    • Machine Learning
    • Visualizations
Made with Slides.com