Skip to main content

Text-based gender prediction for Twitter.

Project description

PyPI-Status PyPI-Versions Build-Status Codecov LICENCE

A packaged version, adapted to Python 3, of the TwitterGenderPredictor code by JT Wolohan, which itself is a Python 2 implementation of Sap et al.’s gender prediction algorithm for Twitter. SPEKS stands for Sap, Park, Eichstaedt, Kern and Stilwell, the first five writers of the paper describing the algorithm implemented here.

>>> from speks import predict_gender_by_tweets
>>> gender = predict_gender_by_tweets(" ".join(["Please Do.", "Join me in praying!"]))

1   Features

  • Supports Python 3.
  • pip-installable.
  • Fully tested.

2   Installation

pip install speks

3   Use

This is a Python 3, packaged version of the TwitterGenderPredictor code by JT Wolohan, which itself is a Python 2 implementation of Sap et al.’s gender prediction algorithm for Twitter. The algorithm should be 90% accurate given a large sample of users and a reasonable amount of data for each user.

You can have the package predict the gender of a Twitter user by providing the predict_gender_by_tweets function with a string containing tweets contents.

>>> from speks import predict_gender_by_tweets
>>> gender = predict_gender_by_tweets(" ".join(["No touchy", "Trial by fire"]))

4   Licensing

Most of the code was released by JT Wolohan under the MPL 2.0 license, and thus I’m releasing my additions under the same license. However, the tokenization code - although slightly adapted - was originally written by Christopher Potts and released under the CC BY-NC-SA 3.0 license, and thus remains released under this license.

5   Contributing

Current package maintainer and author is Shay Palachy (shay.palachy@gmail.com); You are more than welcome to approach him for help. Contributions are very welcomed.

5.1   Installing for development

Clone:

git clone git@github.com:shaypal5/speks.git

Install in development mode, including test dependencies:

cd speks
pip install -e '.[test]'

5.2   Running the tests

To run the tests use:

cd speks
pytest

5.3   Adding documentation

The project is documented using the numpy docstring conventions, which were chosen as they are perhaps the most widely-spread conventions that are both supported by common tools such as Sphinx and result in human-readable docstrings. When documenting code you add to this project, follow these conventions.

Additionally, if you update this README.rst file, use python setup.py checkdocs to validate it compiles.

6   Credits

Algorithm by Sap et al. Original code by JT Wolohan, with tokenization code by Christopher Potts. Packaging and Python 3 adaptation by Shay Palachy.

Original paper reference: Sap, M., Park, G., Eichstaedt, J., Kern, M., Stillwell, D., Kosinski, M., … & Schwartz, H. A. (2014). Developing age and gender predictive lexica over social media. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP) (pp. 1146-1151).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for speks, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size speks-0.0.1-py3-none-any.whl (97.6 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page