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 (; You are more than welcome to approach him for help. Contributions are very welcomed.

5.1 Installing for development


git clone

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

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

speks-0.0.1-py3-none-any.whl (97.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page