Giter Site home page Giter Site logo

smangalik / robust-poststratification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wwbp/robust-poststratification

0.0 0.0 0.0 36 KB

Code associated with Correcting Sociodemographic Selection Biases for Population Prediction from Social Media with Robust Poststratification

Python 100.00%

robust-poststratification's Introduction

Robust Post-Statification

Setup

Install following dependencies

  • python3
  • pip

(Optional) Create and activate a virtual environment

python3 -m venv venv
source venv/bin/activate

Install dependencies

pip install -r requirements.txt

User table, population table, and output must be specified in the arguments. The demographics argument must be valid columns in the user table.

Script can be run using any combination of the following

  • multiple demographics (raking or naive post-stratification)
  • redistribution
  • smooth before binning
  • uninformed smoothing (ignores smoothing_k)

Examples

Single correction factor (income)

python3 robust_poststrat.py --demographics income --smoothing_k 10 --mininum_bin_threshold 50 --user_table /path/to/user_table.csv --population_table /path/to/population_table.csv --output /path/to/output.csv

Single correction factor (income) with redistribution

python3 robust_poststrat.py --demographics income --smoothing_k 10 --mininum_bin_threshold 50 --redistribution --user_table /path/to/user_table.csv --population_table /path/to/population_table.csv --output /path/to/output.csv

Single correction factor (income) with smooth before binning

python3 robust_poststrat.py --demographics income --smoothing_k 10 --mininum_bin_threshold 50 --smooth_before_binning --user_table /path/to/user_table.csv --population_table /path/to/population_table.csv --output /path/to/output.csv

Single correction factor (income) with uninformed smoothing (smoothing_k is ignored)

python3 robust_poststrat.py --demographics income --smoothing_k 10 --mininum_bin_threshold 50 --uninformed_smoothing --user_table /path/to/user_table.csv --population_table /path/to/population_table.csv --output /path/to/output.csv

Multiple correction factors (income + education) using raking

python3 robust_poststrat.py --demographics income education --smoothing_k 10 --mininum_bin_threshold 50 --user_table /path/to/user_table.csv --population_table /path/to/population_table.csv --output /path/to/output.csv

Multiple correction factors (income + education) using naive post-stratification

python3 robust_poststrat.py --demographics income education --smoothing_k 10 --mininum_bin_threshold 50 --naive_poststrat --user_table /path/to/user_table.csv --population_table /path/to/population_table.csv --output /path/to/output.csv

Multiple correction factors (age + gender + income + education) using raking with redistribution

python3 robust_poststrat.py --demographics age gender income education --smoothing_k 10 --mininum_bin_threshold 50 --redistribution --user_table /path/to/user_table.csv --population_table /path/to/population_table.csv --output /path/to/output.csv

Input and Output Format

Dependencies

Citation

If you use this code in your work please cite the following paper:

@article{giorgi2022correcting,
      title={Correcting Sociodemographic Selection Biases for Population Prediction from Social Media}, 
      author={Salvatore Giorgi and Veronica Lynn and Keshav Gupta and Farhan Ahmed and Sandra Matz and Lyle Ungar and H. Andrew Schwartz},
      year={2022},
      journal={Proceedings of the International AAAI Conference on Web and Social Media}, 
}

robust-poststratification's People

Contributors

f4str avatar sjgiorgi avatar smangalik 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.