Giter Club home page Giter Club logo

insight_code's Introduction

Fanalytics: Find Your Bandwagon

NBA league makes >$1 billion from merchandise annually. Meanwhile, there is an online sports forum with 2.7 million NBA fans. In order to capitalize on this large fan group, NBA could push ads for jerseys and gear to those users. On this forum, half of the users have already tagged themselves as fans of a certain team. So, it is convenient to push team-specific ads to those users. However, for the other half of the users, how do we identify their favorite teams?

I took a Natural Language Processing approach to classify fans' teams by their comments and visiting history on other forums. By applying different feature extraction techniques and an ensemble model, the prediction reached a classification accuracy of 64%, which is 20x to the chance level and 2.2x to my MVP model.

With my model, NBA could make about $648k from merchandise. My model could also be applied to other online sports forums.

approach performance

Webapp: NBA Fan Identifier

Type in your comment then we can tell which NBA team you like.

Presentation on the project

Insight Project

Dependencies

Repository folders

  • docker: docker configure files
  • figures: figures used in README
  • notebooks: jupyter notebooks
  • scripts: python functions
  • webapp: code to deploy the webapp

Usage

  • Scrap data

    1. Scrap titles/ids of all comment threads:
      python ./scripts/scraping/pushshift_scrap.py (Also see ./notebooks/pushshift_scrap_submission_reg18.ipynb)
    2. Scrap all comments
      python ./scripts/scraping/praw_scrap.py (Also see ./notebooks/praw_scrap_comments_reg18.ipynb)
    3. Scrap users' visiting history
      python ./scripts/scraping/praw_scrap_history.py (Also see ./notebooks/scrap_user_history.ipynb)
  • Run models
    ./notebooks/Wk3_Final_Model.ipynb

Docker image

I made a Docker image with scrapped data and the final model (Wk3_Final_Model.ipynb). Ask me if you want a copy of the image.

The Docker image was made by running:
sudo docker build -t insight . -f ./docker/Dockerfile

The Docker image can be run by:
sudo docker run --name insight -p 8888:8888 insight

Then go to: localhost:8888/tree
Ask me for the password!

The notebook can be found at:
/home/insight/notebooks/

To clean the container, run:
sudo docker rm insight

Overview of notebooks

  • Week 1: Pilot data scraping and EDA
    ./notebooks/Wk1_pilot_EDA.ipynb
  • Week 2: Building a MVP model
    ./notebooks/Wk2_EDA_MVP.ipynb
  • Week 3: Optimizing the model and creating an ensemble model
    ./notebooks/Wk3_Final_Model.ipynb

List of other scripts

Run Named Entity Recognition with spaCy
./scripts/ner.py

Run TextRank keywords extraction with gensim
./scripts/textrank.py

Load all data
./scripts/load_data.py

Preprocess texts, remove emoji, special charactors, etc.
./scripts/preprocess.py

Standerdize all team names in training data into 3 letters (e.g. TOR)
./scripts/teamname_stdize.py

Calculate AUC for a model
./scripts/cal_auc.py

A simple unit test for cal_auc
./scripts/test_cal_auc.py

Calculate and plot confusion matrix
./scripts/plot_confusion_matrix.py

insight_code's People

Contributors

bearsun avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.