| Name | ethnicolr2 JSON |
| Version |
0.1.4
JSON |
| download |
| home_page | None |
| Summary | Predict Race/Ethnicity Based on Sequence of Characters in the Name |
| upload_time | 2025-09-03 04:06:03 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.9 |
| license | None |
| keywords |
race
ethnicity
names
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# ethnicolr2: Predict Race and Ethnicity From Name
[](https://github.com/appeler/ethnicolr2/actions?query=workflow%3Atest)
[](https://pypi.python.org/pypi/ethnicolr2)
[](https://pepy.tech/project/ethnicolr2)
A Pytorch implementation of
[ethnicolr](https://github.com/appeler/ethnicolr) with new models that
make different assumptions (for instance, this package has models
trained on unique names) than ethnicolr. The package uses the US census
data and the Florida voting registration data to build models to predict
the race and ethnicity (non-Hispanic whites, non-Hispanic Blacks,
Asians, Hispanics, and Other) based on first and last name or just the
last name. For notebooks underlying the package, see
[here](https://github.com/appeler/ethnicolr_v2).
# Caveats and Notes
If you picked a random person with the last name \'Smith\' in the US in
2010 and asked us to guess this person\'s race (as measured by the
census), the best guess is the modal race of the person named Smith
(which you can get from the census popular last name data file). It is
the Bayes Optimal Solution. So what good are predictive models? A few
things\-\--if you want to impute race and ethnicity for last names that
are not in the census file, which can be because of errors, infer the
race and ethnicity in different years than when the census was conducted
(if some assumptions hold), infer the race of people in different
countries (if some assumptions hold), etc. The biggest benefit comes in
cases where both the first and last name are known.
# Install
We strongly recommend installing [ethnicolor2]{.title-ref} inside a
Python virtual environment (see [venv
documentation](https://docs.python.org/3/library/venv.html#creating-virtual-environments))
pip install ethnicolr2
# Example
To predict race/ethnicity using the Florida Last Name Model to a [file
with first and last names](ethnicolr2/data/input-with-header.csv)
import pandas as pd
from ethnicolr2 import pred_fl_last_name, pred_fl_full_name
df = pd.read_csv("ethnicolr2/data/input-with-header.csv")
pred_fl_last_name(df, lname_col = "last_name")
names = [
{"last": "sawyer", "first": "john", "true_race": "nh_white"},
{"last": "torres", "first": "raul", "true_race": "hispanic"},
]
df = pd.DataFrame(names)
df = pred_fl_full_name(df, lname_col = "last", fname_col = "first")
last first true_race preds
0 sawyer john nh_white nh_white
1 torres raul hispanic hispanic
# Authors
Rajashekar Chintalapati, Suriyan Laohaprapanon, and Gaurav Sood
# Contributor Code of Conduct
The project welcomes contributions from everyone! In fact, it depends on
it. To maintain this welcoming atmosphere and to collaborate in a fun
and productive way, we expect contributors to the project to abide by
the [Contributor Code of
Conduct](http://contributor-covenant.org/version/1/0/0/).
## 🔗 Adjacent Repositories
- [appeler/ethnicolr](https://github.com/appeler/ethnicolr) — Predict Race and Ethnicity Based on the Sequence of Characters in a Name
- [appeler/ethnicolor](https://github.com/appeler/ethnicolor) — Race and Ethnicity based on name using data from census, voter reg. files, etc.
- [appeler/instate](https://github.com/appeler/instate) — instate: predict the state of residence from last name using the indian electoral rolls
- [appeler/parsernaam](https://github.com/appeler/parsernaam) — AI name parsing. Predict first or last name using a DL model.
- [appeler/naamkaran](https://github.com/appeler/naamkaran) — generative model for names
Raw data
{
"_id": null,
"home_page": null,
"name": "ethnicolr2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "race, ethnicity, names",
"author": null,
"author_email": "Rajshekar <rajshekar.ch@gmail.com>, Suriyan <suriyant@gmail.com>, Gaurav Sood <gsood07@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/57/7f/0816f72681879e0222bf9f1591b1915356e3086416184046fdeff27db162/ethnicolr2-0.1.4.tar.gz",
"platform": null,
"description": "# ethnicolr2: Predict Race and Ethnicity From Name\n\n[](https://github.com/appeler/ethnicolr2/actions?query=workflow%3Atest)\n[](https://pypi.python.org/pypi/ethnicolr2)\n[](https://pepy.tech/project/ethnicolr2)\n\nA Pytorch implementation of\n[ethnicolr](https://github.com/appeler/ethnicolr) with new models that\nmake different assumptions (for instance, this package has models\ntrained on unique names) than ethnicolr. The package uses the US census\ndata and the Florida voting registration data to build models to predict\nthe race and ethnicity (non-Hispanic whites, non-Hispanic Blacks,\nAsians, Hispanics, and Other) based on first and last name or just the\nlast name. For notebooks underlying the package, see\n[here](https://github.com/appeler/ethnicolr_v2).\n\n# Caveats and Notes\n\nIf you picked a random person with the last name \\'Smith\\' in the US in\n2010 and asked us to guess this person\\'s race (as measured by the\ncensus), the best guess is the modal race of the person named Smith\n(which you can get from the census popular last name data file). It is\nthe Bayes Optimal Solution. So what good are predictive models? A few\nthings\\-\\--if you want to impute race and ethnicity for last names that\nare not in the census file, which can be because of errors, infer the\nrace and ethnicity in different years than when the census was conducted\n(if some assumptions hold), infer the race of people in different\ncountries (if some assumptions hold), etc. The biggest benefit comes in\ncases where both the first and last name are known.\n\n# Install\n\nWe strongly recommend installing [ethnicolor2]{.title-ref} inside a\nPython virtual environment (see [venv\ndocumentation](https://docs.python.org/3/library/venv.html#creating-virtual-environments))\n\n pip install ethnicolr2\n\n# Example\n\nTo predict race/ethnicity using the Florida Last Name Model to a [file\nwith first and last names](ethnicolr2/data/input-with-header.csv)\n\n import pandas as pd\n from ethnicolr2 import pred_fl_last_name, pred_fl_full_name \n df = pd.read_csv(\"ethnicolr2/data/input-with-header.csv\")\n pred_fl_last_name(df, lname_col = \"last_name\")\n\n\n names = [\n {\"last\": \"sawyer\", \"first\": \"john\", \"true_race\": \"nh_white\"},\n {\"last\": \"torres\", \"first\": \"raul\", \"true_race\": \"hispanic\"},\n ]\n df = pd.DataFrame(names)\n df = pred_fl_full_name(df, lname_col = \"last\", fname_col = \"first\")\n\n last first true_race preds\n 0 sawyer john nh_white nh_white\n 1 torres raul hispanic hispanic\n\n# Authors\n\nRajashekar Chintalapati, Suriyan Laohaprapanon, and Gaurav Sood\n\n# Contributor Code of Conduct\n\nThe project welcomes contributions from everyone! In fact, it depends on\nit. To maintain this welcoming atmosphere and to collaborate in a fun\nand productive way, we expect contributors to the project to abide by\nthe [Contributor Code of\nConduct](http://contributor-covenant.org/version/1/0/0/).\n\n\n## \ud83d\udd17 Adjacent Repositories\n\n- [appeler/ethnicolr](https://github.com/appeler/ethnicolr) \u2014 Predict Race and Ethnicity Based on the Sequence of Characters in a Name\n- [appeler/ethnicolor](https://github.com/appeler/ethnicolor) \u2014 Race and Ethnicity based on name using data from census, voter reg. files, etc.\n- [appeler/instate](https://github.com/appeler/instate) \u2014 instate: predict the state of residence from last name using the indian electoral rolls\n- [appeler/parsernaam](https://github.com/appeler/parsernaam) \u2014 AI name parsing. Predict first or last name using a DL model.\n- [appeler/naamkaran](https://github.com/appeler/naamkaran) \u2014 generative model for names\n",
"bugtrack_url": null,
"license": null,
"summary": "Predict Race/Ethnicity Based on Sequence of Characters in the Name",
"version": "0.1.4",
"project_urls": {
"Bug Tracker": "https://github.com/appeler/ethnicolr2/issues",
"Homepage": "https://github.com/appeler/ethnicolr2",
"Repository": "https://github.com/appeler/ethnicolr2"
},
"split_keywords": [
"race",
" ethnicity",
" names"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "07adcb1ab3a4f5961d4156dd3aeac6dced9b0105cc37da2668a61885f51204a8",
"md5": "f9f2317feff305a52a61440b5b4cc3e3",
"sha256": "c11b1e96e142d09fe4fb3523304bf8235393bec5364e7793d4a62b0ff5f9b341"
},
"downloads": -1,
"filename": "ethnicolr2-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f9f2317feff305a52a61440b5b4cc3e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 37831828,
"upload_time": "2025-09-03T04:05:47",
"upload_time_iso_8601": "2025-09-03T04:05:47.726659Z",
"url": "https://files.pythonhosted.org/packages/07/ad/cb1ab3a4f5961d4156dd3aeac6dced9b0105cc37da2668a61885f51204a8/ethnicolr2-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "577f0816f72681879e0222bf9f1591b1915356e3086416184046fdeff27db162",
"md5": "45993d5708e768250d286ee6b19d90e0",
"sha256": "83e240869dbb0b391b47696c47f829a4e2a52185c736d0812d75637370ebd534"
},
"downloads": -1,
"filename": "ethnicolr2-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "45993d5708e768250d286ee6b19d90e0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 37718793,
"upload_time": "2025-09-03T04:06:03",
"upload_time_iso_8601": "2025-09-03T04:06:03.226458Z",
"url": "https://files.pythonhosted.org/packages/57/7f/0816f72681879e0222bf9f1591b1915356e3086416184046fdeff27db162/ethnicolr2-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-03 04:06:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "appeler",
"github_project": "ethnicolr2",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ethnicolr2"
}