Skip to content

Latest commit

 

History

History
171 lines (109 loc) · 4.41 KB

usermanual.md

File metadata and controls

171 lines (109 loc) · 4.41 KB

User Manual

Table of contents

Getting Started

Requirements

Twitter API Developer Account

In order to use Twitter’s API, we have to create a developer account on the Twitter apps site.

  1. Log in or make a Twitter account at Twitter.com

  2. Apply for a twitter developer account here

  3. Make sure you select a student account

  4. Add account details. Click on continue.

  5. Describe in your own words what you are building. Click on continue.

  6. Submit application.

  7. Check your email associated with your twitter and click Confirm your email.

  8. On the welcome screen, click on Create an app.

  9. Fill out your App details and click on Create (its at the bottom of the page). Make sure you don’t try to make a appName that is already taken.

  10. First, click on Keys and tokens. Second, click on create to get access token and access token secret.

    Save your API key, API secret key, Access token, and Access token secret somewhere safe.

  11. Replace the keys in the keys.py

    keys = dict(consumer_key="<consumer key>",
            consumer_secret="<consumer secret>",
            access_token='<access token>',
            access_token_secret='<access token secret>'
            )

System Requirements

  • A decent Multi-Core CPU (4+ cores)
  • macOS or any Linux Distros
  • Python 3.7

Installation

Cloning the Repo

$ git clone https://github.com/shivchander/political-alignment-prediction.git

Dataset

Download the dataset from kaggle.com using your kaggle account

Link to download the dataset

Save the CSV files under a new directory dataset/

Libraries

All the required libraries are in requirements.txt, simply run this file to install all the requirements

$ pip3 install -r requirements.txt

Model

There is a pre-trained model, one could just use that to make the predictions. Or you could train your own model using you own dataset

Using Pre-Trained Model

The model config and weights are saved under model/

To use these models, make sure the path to the file is correct under src/main.py

json_file = open('model/model.json', 'r')
loaded_model.load_weights("model/model.h5")

Training your own Model

Use the ipynb notebook and the intructions from it to train your own model

Download the .h5 file and .json file and save them under model/

Making Predictions

To make final predictions, run the following commands. The code takes twitter handle as an input and outputs the results in form of:

[tweet_score, tweet_prediction, retweet_score, rt_prediction, favtweet_score, ft_prediction, weighted_score, final_prediction]

To run the program, use this:

$ python3 main.py <twitter handle>

Sample Result:

$ python3 main.py RepMarkTakai
...
User                    RepMarkTakai 
tweet_score             0.874494	
tweet_prediction        democrat	
retweet_score           0.939216	
retweet prediction      democrat	
liked_tweet_score       0.841564	
liked_tweet_prediction  democrat	
weighted_score          0.892207	
final_prediction        democrat	

Further Questions

If you need assistance using Deep Pollster or have any further questions:

Contact us:

Shivchander Sudalairaj

Sagar Panwar

If there is a bug in our code, raise an issue on our Github Repo