Race and Ethnicity Prediction from names
Project description
RaceBERT -- A transformer based model to predict race and ethnicty from names
Installation
Using a virtual environment is highly recommended!
pip install racebert
Usage
from racebert import RaceBERT
model = RaceBERT()
# Te predict race
model.predict_race("Barack Obama")
>>> {"label": "nh_black", "score": 0.5196923613548279}
# Predict ethnicity
model.predict_ethnicty("Arjun Gupta")
>>> {"label": "Asian,IndianSubContinent", "score": 0.9612812399864197}
GPU
If you have a GPU, you can speed up the computation by specifying the CUDA device when you instantiate the model.
from racebert import RaceBERT
model = RaceBERT(device=0)
# predict race in batch
model.predict_race(["Barack Obama", "George Bush"])
>>>
[
{"label": "nh_black", "score": 0.5196923613548279},
{"label": "nh_white", "score": 0.8365859389305115}
]
# predict ethnicity in batch
model.predict_ethnicity(["Barack Obama", "George Bush"])
HuggingFace
Alternatively, you can work with the transformers models hosted on the huggingface hub directly.
- Race Model: https://huggingface.co/pparasurama/raceBERT-race
- Ethnicity Model: https://huggingface.co/pparasurama/raceBERT-ethnicity
Please refer to the transformers documentation.
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
racebert-1.0.0.tar.gz
(2.6 kB
view details)
Built Distribution
File details
Details for the file racebert-1.0.0.tar.gz
.
File metadata
- Download URL: racebert-1.0.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c20c65faa5ee1ba8718b46fae492f015f695ac41568f5fa2423fd9b3a8e5af9d |
|
MD5 | 54f435791cf4c363171acd69ee2b79c2 |
|
BLAKE2b-256 | 51fe5fb0b20a4cd5a5ff300972f020c4c6778e242074d59de077f0efa791455d |
File details
Details for the file racebert-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: racebert-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2aec04a2a0e6d0e50b55ff8e2bda0ab95b031ef1dab929a096d0e522f21673e |
|
MD5 | 6b1e586fdfc9505c862340dd3c04cc33 |
|
BLAKE2b-256 | 0a4ac5db8420f5204bf444a7466a3c01d15283191d549b6e24294b6131ec67cd |