ethnicolr2


Nameethnicolr2 JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/appeler/ethnicolr2
SummaryPredict Race/Ethnicity Based on Sequence of Characters in the Name
upload_time2023-12-15 00:38:34
maintainer
docs_urlNone
authorRajashekar Chintalapati, Suriyan Laohaprapanon, Gaurav Sood
requires_python
licenseMIT
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
----------------------------------------------------

.. image:: https://github.com/appeler/ethnicolr2/workflows/test/badge.svg
    :target: https://github.com/appeler/ethnicolr2/actions?query=workflow%3Atest
.. image:: https://img.shields.io/pypi/v/ethnicolr2.svg
    :target: https://pypi.python.org/pypi/ethnicolr2
.. image:: https://static.pepy.tech/badge/ethnicolr2
    :target: 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` 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
   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/>`__.

License
----------

The package is released under the `MIT
License <https://opensource.org/licenses/MIT>`__.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/appeler/ethnicolr2",
    "name": "ethnicolr2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "race ethnicity names",
    "author": "Rajashekar Chintalapati, Suriyan Laohaprapanon, Gaurav Sood",
    "author_email": "rajshekar.ch@gmail.com, suriyant@gmail.com, gsood07@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d0/f8/9096e0fd6312287fbd5ba7f7983bc02c8668ce2fdda0cb818be3ac53288e/ethnicolr2-0.1.1.tar.gz",
    "platform": null,
    "description": "ethnicolr2: Predict Race and Ethnicity From Name\n----------------------------------------------------\n\n.. image:: https://github.com/appeler/ethnicolr2/workflows/test/badge.svg\n    :target: https://github.com/appeler/ethnicolr2/actions?query=workflow%3Atest\n.. image:: https://img.shields.io/pypi/v/ethnicolr2.svg\n    :target: https://pypi.python.org/pypi/ethnicolr2\n.. image:: https://static.pepy.tech/badge/ethnicolr2\n    :target: https://pepy.tech/project/ethnicolr2\n\nA 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>`__.\n\nCaveats and Notes\n-----------------------\n\nIf 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.\n\nInstall\n----------\n\nWe strongly recommend installing `ethnicolor2` inside a Python virtual environment\n(see `venv documentation <https://docs.python.org/3/library/venv.html#creating-virtual-environments>`__)\n\n::\n\n    pip install ethnicolr2\n\nExample\n----------\n\nTo predict race/ethnicity using the Florida Last Name Model to a `file with first and last names <ethnicolr2/data/input-with-header.csv>`__\n\n::\n\n   import pandas as pd\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\nAuthors\n----------\n\nRajashekar Chintalapati, Suriyan Laohaprapanon, and Gaurav Sood\n\nContributor Code of Conduct\n---------------------------------\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\nLicense\n----------\n\nThe package is released under the `MIT\nLicense <https://opensource.org/licenses/MIT>`__.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Predict Race/Ethnicity Based on Sequence of Characters in the Name",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/appeler/ethnicolr2"
    },
    "split_keywords": [
        "race",
        "ethnicity",
        "names"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2973e7310b3fb16d3c0e02cae541dec46a90e6a8e6ac622c992bb45d2b6614e3",
                "md5": "929e156bc5b12d8a6b46fb9b82013bff",
                "sha256": "9eba907eade0ac7696830385d9b437b847854fba73540d313f8c7ddf75bdc713"
            },
            "downloads": -1,
            "filename": "ethnicolr2-0.1.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "929e156bc5b12d8a6b46fb9b82013bff",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 17074803,
            "upload_time": "2023-12-15T00:38:30",
            "upload_time_iso_8601": "2023-12-15T00:38:30.965245Z",
            "url": "https://files.pythonhosted.org/packages/29/73/e7310b3fb16d3c0e02cae541dec46a90e6a8e6ac622c992bb45d2b6614e3/ethnicolr2-0.1.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d0f89096e0fd6312287fbd5ba7f7983bc02c8668ce2fdda0cb818be3ac53288e",
                "md5": "8365a888e407faa571e2713e3dd62a2d",
                "sha256": "2dc02e5fc3672d01bce6f5aa18891e733815665bb58345a53caf2a641f9835fe"
            },
            "downloads": -1,
            "filename": "ethnicolr2-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8365a888e407faa571e2713e3dd62a2d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16944405,
            "upload_time": "2023-12-15T00:38:34",
            "upload_time_iso_8601": "2023-12-15T00:38:34.932617Z",
            "url": "https://files.pythonhosted.org/packages/d0/f8/9096e0fd6312287fbd5ba7f7983bc02c8668ce2fdda0cb818be3ac53288e/ethnicolr2-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-15 00:38:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "appeler",
    "github_project": "ethnicolr2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "ethnicolr2"
}
        
Elapsed time: 0.16007s