Git Product home page Git Product logo

onlinehatespeech_pyladiessea's Introduction

Online Hate Speech Modeling using Python and reddit comment data

Repo for presenting online hate speech project to PyLadies Seattle, 4/28/2016

Primary project repo at https://github.com/eyspahn/OnlineHateSpeech

Link to google slides presentation

Setup

Python packages of particular interest:

  • xgboost: pip install xgboost
    • you may need to sudo yum install gcc before this works
  • gensim: pip install gensim

Full list of packages you'll need:

    numpy, scipy, xgboost, gensim, matplotlib, scikit-learn, nltk, flask

Repo Files:

Scripts:

ExtractComments_pyladies.py

Pulls comments from relevant subreddits out of Kaggle SQL reddit comments file (available here) & saves comments & labels into a pandas dataframe. Takes ~30 minutes to run on a macbook air. (Script is not optimized.) Generates pickled file "labeledhate_pyladies.p"

xgb_CV_woutput_pyladies.py

Run this to perform 5-fold cross validation, while outputting ROC curves, confusion matrices, feature importances, and AUC scores. Takes ~40 minutes to run on a macbook air.

buildxgbmodel_pyladies.py

Run this to build the model for future use/prediction. Creates xgboost model object hatepredictor_pyladies.model & tf-idf object vect_pyladies.p Takes ~10 minutes to run on a macbook air

runfinalmodelpreds.py

Run this to run a comment through the model from the command line & get a prediction. Based on the small subset of data we worked with here.

applyword2vec_pyladies.py

Run to generate 2 word2vec models, one each of hate speech and not-hate speech. Takes <2 minutes to run on a macbook air.

Data

hatepredictor_pyladies.model

The saved xgboost model. Load with

bst.load_model('../data/hatepredictor_pyladies.model')```

#### labeledhate_pyladies.p.zip
Unzip to get a pickle file which is a pandas dataframe of comments and labels.

#### vect_pyladies.p
The saved (trained) TF-IDF object.


### notebooks
```Example_Results.ipynb``` - A notebook to probe the classification & word2vec models.


### webapp_v1.zip
It's not hosted yet, but I have built a website to accept comments & return hate speech classification prediction. Unzip to get a folder containing the flask app. Run it locally by running ```python application.py``` in this ("webapp_v1") directory. Then navigate in your browser to the url shown in the terminal (for me, http://127.0.0.1:5000/). Ctrl+C in the terminal to quit the app.

onlinehatespeech_pyladiessea's People

Contributors

eyspahn avatar

Watchers

James Cloos avatar Adyasha Maharana 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.