Skip to content

Commit 444ee19

Browse files
committed
Update README
1 parent 9ae0a5a commit 444ee19

1 file changed

Lines changed: 47 additions & 3 deletions

File tree

README.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ coverage](https://codecov.io/gh/meirelesff/genderBR/graph/badge.svg)](https://ap
1212

1313
`genderBR` predicts gender from Brazilian first names using data from
1414
the Instituto Brasileiro de Geografia e Estatistica’s Census (2010 and
15-
2022).
15+
2022), covering over 100 thousand unique names. For names that are not
16+
present in the IBGE’s Census, the package now also allows users to
17+
predict gender with a character-level neural network model that
18+
generalise to unseen names.
1619

1720
## Installing
1821

@@ -46,7 +49,7 @@ library(genderBR)
4649
#> Use: citation('genderBR')
4750

4851
get_gender("joão", year = 2022)
49-
#> [1] "Male"
52+
#> [1] NA
5053
get_gender("ana", year = 2022)
5154
#> [1] "Female"
5255
```
@@ -61,7 +64,7 @@ classified as missing (`NA`). An example:
6164

6265
``` r
6366
get_gender("joão")
64-
#> [1] "Male"
67+
#> [1] NA
6568
get_gender("ana")
6669
#> [1] "Female"
6770
```
@@ -136,6 +139,33 @@ df
136139
#> 4 Paula Camargo RS Female
137140
```
138141

142+
### Classifying uncommon Brazilian first names
143+
144+
For names that are not present in the IBGE’s Census, the package now
145+
also allows users to predict gender with a character-level neural
146+
network model that generalises to unseen names. This model was trained
147+
on the IBGE’s Census data and is available on [Hugging
148+
Face](https://huggingface.co/fmeireles/genderBR). Download it with:
149+
150+
``` r
151+
download_gender_model()
152+
```
153+
154+
To use this feature, set the `nn` argument to `TRUE` in the `get_gender`
155+
function (defaults to `FALSE`):
156+
157+
``` r
158+
get_gender("Zusjane", nn = TRUE)
159+
get_gender(c("Lusjane", "Joao"), nn = TRUE, prob = TRUE)
160+
```
161+
162+
Or use the `get_gender_nn` function directly:
163+
164+
``` r
165+
get_gender_nn("Zusjane")
166+
get_gender_nn(c("Maria", "Joao"), prob = TRUE)
167+
```
168+
139169
### Brazilian state abbreviations
140170

141171
The `genderBR` package relies on Brazilian state abbreviations
@@ -163,6 +193,7 @@ state in Brazil. To that end, use the `map_gender` function:
163193

164194
``` r
165195
map_gender("maria")
196+
#> No encoding supplied: defaulting to UTF-8.
166197
#> nome uf freq populacao sexo prop
167198
#> 1 Piauí 22 363139 3118360 11645.19
168199
#> 2 Ceará 23 967042 8452381 11441.06
@@ -176,6 +207,7 @@ the default option).
176207

177208
``` r
178209
map_gender("iris", gender = "m")
210+
#> No encoding supplied: defaulting to UTF-8.
179211
#> nome uf freq populacao sexo prop
180212
#> 1 Goiás 52 840 6003788 m 13.99
181213
#> 2 Tocantins 17 156 1383445 m 11.28
@@ -219,6 +251,18 @@ state, are included in the database.
219251
For more information on the IBGE’s data, please check (in Portuguese):
220252
<https://censo2022.ibge.gov.br/nomes/>
221253

254+
## Neural network model
255+
256+
The neural network model used to predict gender from Brazilian first
257+
names is a bidirectional GRU (embedding dim = 32, hidden dim = 128,
258+
single layer) that operates at the character level. It was trained on
259+
107k names from the IBGE dataset using the `luz` framework with an
260+
80/10/10 train/validation/test split and early stopping. On the held-out
261+
test set, it achieves 95.1% accuracy and 0.141 BCE loss. Model weights
262+
and vocabulary are hosted on [Hugging
263+
Face](https://huggingface.co/fmeireles/genderBR) and downloaded on first
264+
use via `download_gender_model()`.
265+
222266
## Ethical considerations
223267

224268
As the description of the package states, `genderBR` infers gender from

0 commit comments

Comments
 (0)