GithubHelp home page GithubHelp logo

virality-prediction's Introduction

Virality Prediction

Overview

This project aims at predicting the virality of tweets and hashtags on Twitter based on a regression model and a classifier trained by a machine learning algorithms.

Technologies

  • Python
  • MongoDB

Data

The data used is composed of random English tweets crawled from the Twitter API during 3 days.

Setup

  • Install MongoDB: sudo apt-get install mongodb
  • Install the Python libs: sudo pip install -r requirements.txt If you get trouble installing the module h5py, try installing the corresponding package manually first, for example with sudo apt-get install libhdf5-dev on Ubuntu.

Run

  1. Fill your Twitter API key in authExample.py and rename the file auth.py
  2. Execute python stream.py to get as many tweets as you want (at least 3 days if you can)
  3. Remove the duplicates and add an index on the tweets ID
    • Execute the shell command mongo
    • In the mongo shell, execute db.Tweets.createIndex({id: 1}, {unique: true, dropDups: true})
  4. Execute python retweetUpdater.py a few days later to update the number of retweets of each tweet. This timeframe will be the one of your model when predicting the virality of a tweet or hashtag
  5. Predict the virality of previously retrieved hashtags: python viralityPrediction.py. This step can be replaced by the following ones:
    • Extract the features from the tweets stored in database: python featuresExtractor.py
    • Train your regression model or classifier to predict the number of retweets or the tweet virality class based on the features: python regression.py
    • Build an inverted index, giving a list of tweets for each hashtag: python hashtagIndex.py
    • Predict the virality of hashtags: python viralityPrediction.py
  6. Predict the virality of new hashtags using current tweets: use python twitterSearch.py to retrieve tweets IDs from the Twitter API for a given hashtag. When you have retrieved the features for each tweet, you can feed those features to viralityPrediction.py in order to output a retweet count or virality prediction

virality-prediction's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.