namesex_light
Namesex_light is a lighweight package that predicts the gender tendency of Chinese given names. This module comes with a L2 regularized logistic regression trained on 10,730 Chinese given names (in traditional Chinese) with reliable gender lables collected from public data. The predict() function takes a list of names and output predicted gender tendency (1 for male and 0 for female) or probability of being a male name. Namesex_light has a sister project, namesex, that performs similar tasks with higher accuracy.
Additional information about namesex and namesex_light can be found in another document (in Chinese).
The prediction performance evaluated by ten-fold cross validation is:
Metric |
Performance |
Performance Std. Dev. |
Accuracy |
0.8957 |
0.007327 |
F1 |
0.8920 |
0.007873 |
Precision |
0.8852 |
0.012238 |
Recall |
0.8991 |
0.008936 |
Logloss |
114.35 |
6.413972 |
Use pip/pip3 to install namesex_light.:
pip install namesex_light
To use namesex_light, pass in an array or list of given names to predict(). For each element in the input list, predict() returns 1 or 0 for male or female prediction. Set “predprob = True” to return probability of being a male name. The following is a simple sample code.:
>>> import namesex_light >>> nsl = namesex_light.namesex_light() >>> nsl.predict(['民豪', '愛麗', '志明']) array([1, 0, 1]) >>> nsl.predict(['民豪', '愛麗', '志明'], predprob=True) array([0.99968932, 0.00530066, 0.9938986 ])
Note that namesex_light was trained using Chinese given names only. However, it may be used to classifier translated names as well:
>>> nsl.predict(['阿波羅', '阿波羅', '雷', '艾美', '布蘭妮', '阿曼達']) array([1, 1, 1, 0, 0, 1])
This module is intended for a quick plug-and-play. The original training dataset is not included.
Testing Dataset
This package comes with a small testing dataset that was not used for model training. The following sample code illustrate a simple usage.:
>>> testdata = namesex_light.testdata()
>>> nsl = namesex_light.namesex_light()
>>> pred = nsl.predict(testdata.gname)
>>> print("The first 5 given names are: {}".format(testdata.gname[0:5]))
The first 5 given names are: ['翊如', '妤庭', '諆璋', '大閎', '和維']
>>> print(" and their sex: {}".format(testdata.sex[0:5]))
and their sex: [0, 0, 1, 1, 1]
>>> print(" and their predicted sex:{}".format(pred[0:5]))
and their predicted sex:[0 0 1 1 1]
>>> accuracy = np.sum(pred == testdata.sex) / len(pred)
>>> print(" Prediction accuracy = {}".format(accuracy))
Prediction accuracy = 0.8627450980392157
Note that the accuracy is slightly lower compared to the accuracy of ten-fold cross valudation. I guess this is normal since this testset is collected from a source that is different from the training dataset.
Metadata
Release files for namesex-light 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| namesex_light-0.2.1.tar.gz | 4.7 kB | Without provenance | Details for namesex_light-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| namesex_light-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for namesex_light-0.2.1-py3-none-any.whl |
Total release size: 74.2 kB
Release files / namesex_light-0.2.1.tar.gz
| Download URL | namesex_light-0.2.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
338b8142e0500270a324e63a7f42b615913def257246f8328da3fcc8eea2f5ea
|
|
BLAKE2b-256 checksum How to use checksums |
6fd2472d16e588449fa1cae698fb7f420347b5865420695a8a1980959bcc27c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / namesex_light-0.2.1-py3-none-any.whl
| Download URL | namesex_light-0.2.1-py3-none-any.whl |
|---|---|
| Size | 69.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e426353bb0ed48cbf990a72ebaf16b69403fa7e4dbb6528d5912a77cd9c2f49c
|
|
BLAKE2b-256 checksum How to use checksums |
22da3a02cc2b5c629fff8c18f23922168c5e7c0385a58e31f28b8f9abb78f15a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for namesex-light 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.