Skip to main content

根据名称中的字符序列预测种族/民族

项目描述

种族:从名称预测种族和民族

https://github.com/appeler/ethnicolr/workflows/test/badge.svg https://ci.appveyor.com/api/projects/status/u9fe72hn8nnhmaxt?svg=true https://img.shields.io/pypi/v/ethnicolr.svg https://anaconda.org/soodoku/ethnicolr/badges/version.svg https://pepy.tech/badge/ethnicolr

我们利用 Skiena 及其同事收集的美国人口普查数据、佛罗里达州投票登记数据和维基百科数据,根据名字和姓氏或仅姓氏来预测种族和民族。我们预测比赛的粒度取决于数据集。例如,Skiena 等人。维基百科的数据是在族群层面,而我们在模型中使用的人口普查数据(原始数据有额外的美洲原住民和混血儿类别)仅在非西班牙裔白人、非西班牙裔黑人、亚洲人和西班牙裔之间进行分类.

角钱竞赛

DIME 数据中所有人的种族数据 发布在这里底层 Python 脚本发布在这里

注意事项和注意事项

如果您在 2010 年从美国随机挑选了一个姓氏为“史密斯”的人,并要求我们猜测此人的种族(与人口普查一样粗略地衡量),那么最好的猜测将基于汇总的人口普查文件中的可用信息. 这是贝叶斯最优解。那么只有姓氏的预测模型有什么用呢?一些事情——如果你想更细化地估算种族,猜测不同年份的人的种族(如果某些假设成立,则比进行人口普查时进行),猜测不同国家的人的种族(再次假设某些假设持有),当名字略有不同时(同样有一些假设)等等。最大的好处来自于名字和姓氏都知道的情况。

安装

我们强烈建议在 Python 虚拟环境中安装种族颜色(请参阅venv文档

pip install ethnicolr

或者

conda install -c soodoku ethnicolr
笔记:
  • 这些模型使用 Python 3.7 和 3.8 在 TensorFlow 2.x 上运行和验证,并且更低版本可以工作。TensorFlow 1.x 已被弃用。

  • 如果您在 Windows 上安装,Theano 安装通常需要管理员。shell 上的权限。

通用 API

要查看任何函数的可用命令行选项,请输入 <function-name> --help

# census_ln --help
usage: census_ln [-h] [-y {2000,2010}] [-o OUTPUT] -l LAST input

Appends Census columns by last name

positional arguments:
  input                 Input file

optional arguments:
  -h, --help            show this help message and exit
  -y {2000,2010}, --year {2000,2010}
                        Year of Census data (default=2000)
  -o OUTPUT, --output OUTPUT
                        Output file with Census data columns
  -l LAST, --last LAST  Name or index location of column contains the last
                        name

例子

要将 2010 年的人口普查数据附加到没有列标题且第一列带有姓氏的文件中,请使用-l 0

census_ln -y 2010 -o output-census2010.csv -l 0 input-without-header.csv

要将 2010 年的人口普查数据附加到第一行具有列标题的文件中,请使用-l选项指定带有姓氏的列名,其余部分保持不变:

census_ln -y 2010 -o output-census2010.csv -l last_name input-with-header.csv

要使用维基百科全名模型预测种族/民族,如果输入文件没有任何列标题,则必须使用-l-f分别指定携带姓氏和名字的列的索引(第一列有索引0)。

pred_wiki_name -o output-wiki-pred-race.csv -l 0 -f 1 input-without-header.csv

并且要使用维基百科全名模型预测具有列标题的文件的种族/民族,您可以分别使用-l-f标志指定姓氏和名字的列名。

pred_wiki_name -o output-wiki-pred-race.csv -l last_name -f first_name input-with-header.csv

功能

我们公开了 6 个函数,每个函数都采用 pandas DataFrame 或 CSV。如果 CSV 没有标题,我们对数据的位置做出一些假设:

  • census_ln(df,namecol,年份=2000)

    • 它能做什么:

      • 去除多余的空间

      • 对于人口普查文件中的姓名,它会附加有关所提供姓名属于某个种族/民族的概率的相关数据

参数

df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

namecol : {string, list, int}包含姓氏的列的名称或位置的字符串或列表

Year : {2000, 2010},默认=2000使用的人口普查年份

  • 输出:将以下列追加到 pandas DataFrame 或 CSV:pctwhite、pctblack、pctapi、pctaian、pct2prace、pcthispanic。请参阅此处 了解列名的含义。

    >>> import pandas as pd
    
    >>> from ethnicolr import census_ln, pred_census_ln
    
    >>> names = [{'name': 'smith'},
    ...         {'name': 'zhang'},
    ...         {'name': 'jackson'}]
    
    >>> df = pd.DataFrame(names)
    
    >>> df
          name
    0    smith
    1    zhang
    2  jackson
    
    >>> census_ln(df, 'name')
          name pctwhite pctblack pctapi pctaian pct2prace pcthispanic
    0    smith    73.35    22.22   0.40    0.85      1.63        1.56
    1    zhang     0.61     0.09  98.16    0.02      0.96        0.16
    2  jackson    41.93    53.02   0.31    1.04      2.18        1.53
  • pred_census_ln(df, namecol, year=2000, num_iter=100, conf_int=0.9)

    参数

    df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

    namecol : {string, list, int}包含姓氏的列的名称或位置的字符串或列表

    year : {2000, 2010},默认=2000使用的人口普查年份

    num_iter : int, default=100计算模型不确定性的迭代次数

    conf_int :浮点数,默认 = 1.0预测类的置信区间

    • 输出:将以下列附加到 pandas DataFrame 或 CSV:race(白人、黑人、亚洲人或西班牙裔)、api(亚洲人的百分比)、黑色、西班牙裔、白人。对于每场比赛,它将提供置信区间的平均值、标准误差、下限和上限

    (使用上面示例中的相同数据框)

    >>> census_ln(df, 'name')
          name pctwhite pctblack pctapi pctaian pct2prace pcthispanic
    0    smith    73.35    22.22   0.40    0.85      1.63        1.56
    1    zhang     0.61     0.09  98.16    0.02      0.96        0.16
    2  jackson    41.93    53.02   0.31    1.04      2.18        1.53
    
    >>> census_ln(df, 'name', 2010)
          name   race pctwhite pctblack pctapi pctaian pct2prace pcthispanic
    0    smith  white     70.9    23.11    0.5    0.89      2.19         2.4
    1    zhang    api     0.99     0.16  98.06    0.02      0.62        0.15
    2  jackson  black    39.89    53.04   0.39    1.06      3.12         2.5
    
    >>> pred_census_ln(df, 'name')
          name   race       api     black  hispanic     white
    0    smith  white  0.002019  0.247235  0.014485  0.736260
    1    zhang    api  0.997807  0.000149  0.000470  0.001574
    2  jackson  black  0.002797  0.528193  0.014605  0.454405
  • pred_wiki_ln(df,namecol,num_iter=100,conf_int=0.9)

    • 它能做什么:

    参数

    df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

    namecol : {string, list, int}包含姓氏的列的名称或位置的字符串或列表

    num_iter : int, default=100计算模型不确定性的迭代次数

    conf_int :浮点数,默认 = 1.0预测类的置信区间

    • 输出:将以下列追加到 pandas DataFrame 或 CSV:race(分类变量 - 概率最高的类别)、“Asian,GreaterEastAsian,EastAsian”、“Asian,GreaterEastAsian,Japanese”、“Asian,IndianSubContinent”、“GreaterAfrican,非洲人”、“大非洲人、穆斯林”、“大欧洲人、英国人”、“大欧洲人、东欧人”、“大欧洲人、犹太人”、“大欧洲人、西欧人、法国人”、“大欧洲人、西欧人、日耳曼人”、“大欧洲人、西欧人、西班牙人” , “GreaterEuropean,WestEuropean,Italian”,“GreaterEuropean,WestEuropean,Nordic”。对于每场比赛,它将提供置信区间的平均值、标准误差、下限和上限

    >>> import pandas as pd
    
    >>> names = [
    ...             {"last": "smith", "first": "john", "true_race": "GreaterEuropean,British"},
    ...             {
    ...                 "last": "zhang",
    ...                 "first": "simon",
    ...                 "true_race": "Asian,GreaterEastAsian,EastAsian",
    ...             },
    ...         ]
    >>> df = pd.DataFrame(names)
    
    >>> from ethnicolr import pred_wiki_ln, pred_wiki_name
    
    >>> odf = pred_wiki_ln(df,'last')
    ['Asian,GreaterEastAsian,EastAsian', 'Asian,GreaterEastAsian,Japanese', 'Asian,IndianSubContinent', 'GreaterAfrican,Africans', 'GreaterAfrican,Muslim', 'GreaterEuropean,British', 'GreaterEuropean,EastEuropean', 'GreaterEuropean,Jewish', 'GreaterEuropean,WestEuropean,French', 'GreaterEuropean,WestEuropean,Germanic', 'GreaterEuropean,WestEuropean,Hispanic', 'GreaterEuropean,WestEuropean,Italian', 'GreaterEuropean,WestEuropean,Nordic']
    
    >>> odf
       last  first  ... GreaterEuropean,WestEuropean,Nordic_ub                              race
    0  Smith   john  ...                               0.004559           GreaterEuropean,British
    1  Zhang  simon  ...                               0.004076  Asian,GreaterEastAsian,EastAsian
    
    [2 rows x 57 columns]
    
    >>> odf.iloc[0,:8]
    last                                                       Smith
    first                                                       john
    true_race                                GreaterEuropean,British
    Asian,GreaterEastAsian,EastAsian_mean                   0.004554
    Asian,GreaterEastAsian,EastAsian_std                    0.003358
    Asian,GreaterEastAsian,EastAsian_lb                     0.000535
    Asian,GreaterEastAsian,EastAsian_ub                     0.000705
    Name: 0, dtype: object
  • pred_wiki_name(df,namecol,num_iter=100,conf_int=0.9)

    • 它能做什么:

    参数

    df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

    namecol : {string, list}包含名字、姓氏、中间名和后缀(如果有)的列的名称或位置的字符串或列表。名字和姓氏列是必需的。如果没有后缀列的中间名,则假定没有中间名或后缀。

    num_iter : int, default=100计算模型不确定性的迭代次数

    conf_int :浮点数,默认 = 1.0预测类的置信区间

    • 输出:将以下列附加到 pandas DataFrame 或 CSV:race(分类变量 - 概率最高的类别)、“Asian、GreaterEastAsian、EastAsian”、“Asian、GreaterEastAsian、Japanese”、“Asian,IndianSubContinent”、“GreaterAfrican、非洲人”、“大非洲人、穆斯林”、“大欧洲人、英国人”、“大欧洲人、东欧人”、“大欧洲人、犹太人”、“大欧洲人、西欧人、法国人”、“大欧洲人、西欧人、日耳曼人”、“大欧洲人、西欧人、西班牙人” , “GreaterEuropean,WestEuropean,Italian”,“GreaterEuropean,WestEuropean,Nordic”。对于每场比赛,它将提供置信区间的平均值、标准误差、下限和上限

    (使用上面示例中的相同数据框)

    >>> odf = pred_wiki_name(df, 'last', 'first')
    ['Asian,GreaterEastAsian,EastAsian', 'Asian,GreaterEastAsian,Japanese', 'Asian,IndianSubContinent', 'GreaterAfrican,Africans', 'GreaterAfrican,Muslim', 'GreaterEuropean,British', 'GreaterEuropean,EastEuropean', 'GreaterEuropean,Jewish', 'GreaterEuropean,WestEuropean,French', 'GreaterEuropean,WestEuropean,Germanic', 'GreaterEuropean,WestEuropean,Hispanic', 'GreaterEuropean,WestEuropean,Italian', 'GreaterEuropean,WestEuropean,Nordic']
    
    >>> odf
       last  first  ... GreaterEuropean,WestEuropean,Nordic_ub                              race
    0  Smith   john  ...                               0.000236           GreaterEuropean,British
    1  Zhang  simon  ...                               0.000021  Asian,GreaterEastAsian,EastAsian
    
    [2 rows x 58 columns]
    
    >>> odf.iloc[1,:8]
    last                                                                Zhang
    first                                                               simon
    true_race                                Asian,GreaterEastAsian,EastAsian
    Asian,GreaterEastAsian,EastAsian_mean                            0.890619
    Asian,GreaterEastAsian,EastAsian_std                             0.119097
    Asian,GreaterEastAsian,EastAsian_lb                              0.391496
    Name: 1, dtype: object
  • pred_fl_reg_ln(df,namecol,num_iter=100,conf_int=0.9)

    • 它能做什么?:

    参数

    df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

    namecol : {string, list, int}包含姓氏的列的名称或位置的字符串或列表

    num_iter : int, default=100计算模型不确定性的迭代次数

    conf_int :浮点数,默认 = 1.0预测类的置信区间

    • 输出:将以下列附加到 pandas DataFrame 或 CSV:种族(白人、黑人、亚洲人或西班牙裔)、亚洲人(亚洲人的百分比)、西班牙裔、nh_black、nh_white。对于每场比赛,它将提供置信区间的平均值、标准误差、下限和上限

    >>> import pandas as pd
    
    >>> names = [
    ...             {"last": "sawyer", "first": "john", "true_race": "nh_white"},
    ...             {"last": "torres", "first": "raul", "true_race": "hispanic"},
    ...         ]
    
    >>> df = pd.DataFrame(names)
    
    >>> from ethnicolr import pred_fl_reg_ln, pred_fl_reg_name, pred_fl_reg_ln_five_cat, pred_fl_reg_name_five_cat
    
    >>> odf = pred_fl_reg_ln(df, 'last')
    ['asian', 'hispanic', 'nh_black', 'nh_white']
    
    >>> odf
       last first true_race  asian_mean  asian_std  ...  nh_black_ub  nh_white_mean  nh_white_std  nh_white_lb  nh_white_ub      race
    0  Sawyer  john  nh_white    0.004004   0.004483  ...     0.015442       0.908452      0.035121     0.722879     0.804443  nh_white
    1  Torres  raul  hispanic    0.005882   0.002249  ...     0.005305       0.182575      0.072142     0.074511     0.090856  hispanic
    
    [2 rows x 21 columns]
    
    >>> odf.iloc[0]
    last               Sawyer
    first                john
    true_race        nh_white
    asian_mean       0.004004
    asian_std        0.004483
    asian_lb         0.000899
    asian_ub          0.00103
    hispanic_mean    0.034227
    hispanic_std      0.01294
    hispanic_lb      0.017406
    hispanic_ub      0.017625
    nh_black_mean    0.053317
    nh_black_std     0.028634
    nh_black_lb      0.010537
    nh_black_ub      0.015442
    nh_white_mean    0.908452
    nh_white_std     0.035121
    nh_white_lb      0.722879
    nh_white_ub      0.804443
    race             nh_white
    Name: 0, dtype: object
  • pred_fl_reg_name(df,namecol,num_iter=100,conf_int=0.9)

    • 它能做什么:

      • 删除多余的空间。

      • 使用全名FL模型 来预测种族和民族。

    参数

    df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

    namecol : {string, list}包含名字、姓氏、中间名和后缀(如果有)的列的名称或位置的字符串或列表。名字和姓氏列是必需的。如果没有后缀列的中间名,则假定没有中间名或后缀。

    num_iter : int, default=100计算模型不确定性的迭代次数

    conf_int :浮点数,默认 = 1.0预测类的置信区间

    • 输出:将以下列附加到 pandas DataFrame 或 CSV:种族(白人、黑人、亚洲人或西班牙裔)、亚洲人(亚洲人的百分比)、西班牙裔、nh_black、nh_white。对于每场比赛,它将提供置信区间的平均值、标准误差、下限和上限

    (使用上面示例中的相同数据框)

    >>> odf = pred_fl_reg_name(df, 'last', 'first')
    ['asian', 'hispanic', 'nh_black', 'nh_white']
    
    >>> odf
       last first true_race  asian_mean  ...  nh_black_ub  nh_white_mean  nh_white_std  nh_white_lb  nh_white_ub      race
    0  Sawyer  john  nh_white    0.001196  ...     0.005450       0.971152      0.015757     0.915592     0.918630  nh_white
    1  Torres  raul  hispanic    0.004770  ...     0.000885       0.066303      0.028486     0.022593     0.024143  hispanic
    
    [2 rows x 22 columns]
    
    >>> odf.iloc[1]
    last                  Torres
    first                   raul
    true_race           hispanic
    asian_mean           0.00477
    asian_std           0.002943
    asian_lb            0.000904
    asian_ub            0.001056
    hispanic_mean         0.9251
    hispanic_std        0.032224
    hispanic_lb         0.829494
    hispanic_ub           0.8385
    nh_black_mean       0.003826
    nh_black_std        0.002735
    nh_black_lb         0.000838
    nh_black_ub         0.000885
    nh_white_mean       0.066303
    nh_white_std        0.028486
    nh_white_lb         0.022593
    nh_white_ub         0.024143
    race                hispanic
    Name: 1, dtype: object
  • pred_fl_reg_ln_five_cat(df,namecol,num_iter=100,conf_int=0.9)

    • 它能做什么?:

    参数

    df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

    namecol : {string, list, int}包含姓氏的列的名称或位置的字符串或列表

    num_iter : int, default=100计算模型不确定性的迭代次数

    conf_int :浮点数,默认 = 1.0预测类的置信区间

    • 输出:将以下列附加到 pandas DataFrame 或 CSV:种族(白人、黑人、亚洲人、西班牙裔或其他人)、亚洲人(亚洲人的百分比机会)、西班牙裔、nh_black、nh_white 等。对于每场比赛,它将提供置信区间的平均值、标准误差、下限和上限

    (使用上面示例中的相同数据框)

    >>> odf = pred_fl_reg_ln_five_cat(df,'last')
    ['asian', 'hispanic', 'nh_black', 'nh_white', 'other']
    
    >>> odf
       last first true_race  asian_mean  asian_std  ...  nh_white_lb  nh_white_ub  other_mean  other_std  other_lb  other_ub      race
    0  Sawyer  john  nh_white    0.142867   0.046145  ...     0.203204     0.221313    0.235889   0.023794  0.192840  0.193671  nh_white
    1  Torres  raul  hispanic    0.101397   0.028399  ...     0.090068     0.100212    0.238645   0.034070  0.136617  0.145928  hispanic
    
    [2 rows x 26 columns]
    
    >>> odf.iloc[0]
    last                  Sawyer
    first                   john
    true_race           nh_white
    asian_mean          0.142867
    asian_std           0.046145
    asian_lb            0.067382
    asian_ub            0.073285
    hispanic_mean       0.068199
    hispanic_std        0.020641
    hispanic_lb          0.02565
    hispanic_ub         0.030017
    nh_black_mean       0.239793
    nh_black_std        0.076287
    nh_black_lb         0.084239
    nh_black_ub         0.085626
    nh_white_mean       0.313252
    nh_white_std        0.046173
    nh_white_lb         0.203204
    nh_white_ub         0.221313
    other_mean          0.235889
    other_std           0.023794
    other_lb             0.19284
    other_ub            0.193671
    race                nh_white
    Name: 0, dtype: object
  • pred_fl_reg_name_five_cat(df,namecol,num_iter=100,conf_int=0.9)

    • 它能做什么:

      • 删除多余的空间。

      • 使用全名FL模型 来预测种族和民族。

    参数

    df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

    namecol : {string, list}包含名字、姓氏、中间名和后缀(如果有)的列的名称或位置的字符串或列表。名字和姓氏列是必需的。如果没有后缀列的中间名,则假定没有中间名或后缀。

    num_iter : int, default=100计算模型不确定性的迭代次数

    conf_int :浮点数,默认 = 1.0预测类的置信区间

    • 输出:将以下列附加到 pandas DataFrame 或 CSV:种族(白人、黑人、亚洲人、西班牙裔或其他)、亚洲人(亚洲人的百分比机会)、西班牙裔、nh_black、nh_white 等。对于每场比赛,它将提供置信区间的平均值、标准误差、下限和上限

    (使用上面示例中的相同数据框)

    >>> odf = pred_fl_reg_name_five_cat(df, 'last','first')
    ['asian', 'hispanic', 'nh_black', 'nh_white', 'other']
    
    >>> odf
       last first true_race  asian_mean  asian_std  ...  nh_white_lb  nh_white_ub  other_mean  other_std  other_lb  other_ub      race
    0  Sawyer  john  nh_white    0.194250   0.120314  ...     0.126987     0.167742    0.259069   0.030386  0.142455  0.177375  nh_white
    1  Torres  raul  hispanic    0.081465   0.038318  ...     0.019312     0.020782    0.158614   0.039180  0.081994  0.083105  hispanic
    
    [2 rows x 26 columns]
    
    >>> odf.iloc[1]
    last                  Torres
    first                   raul
    true_race           hispanic
    asian_mean          0.081465
    asian_std           0.038318
    asian_lb            0.032789
    asian_ub            0.034667
    hispanic_mean       0.646059
    hispanic_std        0.144663
    hispanic_lb         0.188246
    hispanic_ub         0.219772
    nh_black_mean       0.037737
    nh_black_std        0.045439
    nh_black_lb         0.006477
    nh_black_ub         0.006603
    nh_white_mean       0.076125
    nh_white_std        0.059213
    nh_white_lb         0.019312
    nh_white_ub         0.020782
    other_mean          0.158614
    other_std            0.03918
    other_lb            0.081994
    other_ub            0.083105
    race                hispanic
    Name: 1, dtype: object
  • pred_nc_reg_name(df,namecol,num_iter=100,conf_int=0.9)

    • 它能做什么:

      • 删除多余的空间。

      • 使用全名NC模型 来预测种族和民族。

    参数

    df : {DataFrame, csv} CSV 文件的 Pandas 数据框包含要推断的个人姓名

    namecol : {string, list}包含名字、姓氏、中间名和后缀(如果有)的列的名称或位置的字符串或列表。名字和姓氏列是必需的。如果没有后缀列的中间名,则假定没有中间名或后缀。

    num_iter : int, default=100计算模型不确定性的迭代次数

    conf_int :浮点数,默认 = 1.0预测类的置信区间

    • 输出:将以下列附加到 pandas DataFrame 或 CSV:种族 + 种族。密码本在 这里。对于每场比赛,它将提供置信区间的平均值、标准误差、下限和上限

    >>> import pandas as pd
    
    >>> names = [
    ...             {"last": "hernandez", "first": "hector", "true_race": "HL+O"},
    ...             {"last": "zhang", "first": "simon", "true_race": "NL+A"},
    ...         ]
    
    >>> df = pd.DataFrame(names)
    
    >>> from ethnicolr import pred_nc_reg_name
    
    >>> odf = pred_nc_reg_name(df, 'last','first')
    ['HL+A', 'HL+B', 'HL+I', 'HL+M', 'HL+O', 'HL+W', 'NL+A', 'NL+B', 'NL+I', 'NL+M', 'NL+O', 'NL+W']
    
    >>> odf
          last   first true_race  HL+A_mean  HL+A_std       HL+A_lb       HL+A_ub  HL+B_mean  ...   NL+M_ub  NL+O_mean  NL+O_std   NL+O_lb   NL+O_ub  NL+W_mean  NL+W_std   NL+W_lb   NL+W_ub  race
    0  hernandez  hector      HL+O   0.000054  0.000354  5.833132e-10  4.291366e-09   0.009606  ...  0.000416   0.090123  0.036310  0.000705  0.003757   0.021228  0.021222  0.000368  0.001230  HL+O
    1      zhang   simon      NL+A   0.000603  0.002808  1.988648e-07  2.766486e-07   0.000026  ...  0.000086   0.125159  0.042818  0.050547  0.057208   0.003149  0.005437  0.000210  0.000225  NL+A
    
    [2 rows x 54 columns]
    
    >>> odf.iloc[0]
    last                hernandez
    first                  hector
    true_race                HL+O
    HL+A_mean            0.000054
    HL+A_std             0.000354
    HL+A_lb                   0.0
    HL+A_ub                   0.0
    HL+B_mean            0.009606
    HL+B_std             0.040739
    HL+B_lb                   0.0
    HL+B_ub              0.000003
    HL+I_mean            0.001605
    HL+I_std             0.004569
    HL+I_lb                   0.0
    HL+I_ub                   0.0
    HL+M_mean            0.147628
    HL+M_std             0.215733
    HL+M_lb              0.001253
    HL+M_ub              0.001297
    HL+O_mean             0.36902
    HL+O_std             0.132249
    HL+O_lb              0.002289
    HL+O_ub              0.019187
    HL+W_mean            0.264246
    HL+W_std             0.090536
    HL+W_lb              0.001782
    HL+W_ub              0.015628
    NL+A_mean            0.012004
    NL+A_std             0.010873
    NL+A_lb              0.000121
    NL+A_ub              0.000281
    NL+B_mean            0.010891
    NL+B_std              0.01404
    NL+B_lb              0.000094
    NL+B_ub              0.000383
    NL+I_mean            0.005182
    NL+I_std             0.008259
    NL+I_lb              0.000009
    NL+I_ub              0.000068
    NL+M_mean            0.068412
    NL+M_std              0.08564
    NL+M_lb              0.000172
    NL+M_ub              0.000416
    NL+O_mean            0.090123
    NL+O_std              0.03631
    NL+O_lb              0.000705
    NL+O_ub              0.003757
    NL+W_mean            0.021228
    NL+W_std             0.021222
    NL+W_lb              0.000368
    NL+W_ub               0.00123
    race                     HL+O
    Name: 0, dtype: object

应用

为了说明如何使用该软件包,我们估算了 FEC 在 2000 年和 2010 年记录的竞选贡献者的种族,并按种族计算竞选贡献。

DIME 数据中所有人的种族数据发布在这里底层 Python 脚本发布在这里

数据

特别是,我们利用了2000 年2010 年人口普查中的姓氏种族数据、Skiena 及其同事收集的维基百科数据以及 2017 年初的佛罗里达州选民登记数据

评估

  1. SCAN Health Plan 是一项为加利福尼亚州超过 200,000 名成员提供服务的医疗保险优势计划,它使用该软件更好地评估所服务人群之间的种族健康差异。他们只有大约 47% 的成员的种族数据,所以用它来了解剩余 53% 的种族。在他们有标签的数据中,他们发现姓氏模型的 AUC 为 0.9,准确率为 83%。

  2. NC 数据评估:https ://github.com/appeler/nc_race_ethnicity

作者

Suriyan Laohaprapanon、Gaurav Sood 和 Bashar Naji

贡献者行为准则

该项目欢迎大家的贡献!事实上,这取决于它。为了保持这种欢迎气氛,并以有趣和富有成效的方式进行协作,我们希望项目的贡献者遵守贡献者行为准则

执照

该软件包是在MIT License下发布的。

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布