Predict race from name and location
Project description
pyethnicity:
What is it?
pyethnicity is a Python package to predict race from name and location. To the best of the author's knowledge, it outperforms all existing open-source models. It does this by training a Bidirectional LSTM on the largest, most comprehensive dataset of name and self-reported race thus far. It uses voter registration data from all 50 states. Additionally, it incorporates location features and improved versions of Bayesian Improved Surname Geocoding and Bayesian Improved Firstname Surname Geocoding to form an ensemble model that achieves up to 36.8% higher F1 scores than the next-best performing model.
pyethnicity
rethnicity
ethnicolr
Please see the correpsonding paper "Can We Trust Race Prediction?" for more details.
Usage:
Please see https://pyethnicity.readthedocs.io/en/latest/ for full documentation.
Installing
The easiest way is to install pyethnicity is from PyPI using pip:
pip install pyethnicity
Running
Pyethnicity exposes several functions. Currently, it only support only tract and ZCTA-level features, although county and state-level features are planned. Each function takes in a scalar or array-like of inputs and returns a pandas DataFrame of the input and the predictions. Note that pyethnicity expects the census tract to be in the format of 2-digit state FIPS, 3-digit county FIPS, and 6-digit tract.
import pyethnicity
zcta = 27106
tract = 72153750502
first_name = "cangyuan"
last_name = "luo"
pyethnicity.bisg(last_name, zcta, geo_type="zcta")
pyethnicity.bifsg(first_name, last_name, tract, geo_type="tract")
pyethnicity.predict_race_fl(first_name, last_name)
pyethnicity.predict_race_flg(first_name, last_name, tract, geo_type="tract")
pyethnicity.predict_race(first_name, last_name, zcta, geo_type="zcta")
TODO:
This package is still in active development. Please report any issues!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyethnicity-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09e075a6ba70e20529081f1f9ac01098f94dd7e10c4d4b199c530da1009b203c |
|
MD5 | 54d03fa96dcc39b80b030c104076e1b6 |
|
BLAKE2b-256 | 0f5e69f8c1f5dfba642b2be9a64b4203283e6413aa6bf701dc14309982d90567 |