Originally published on LinkedIn August 30, 2018.

It is amusing to validate the observations from the legendary philosophers. This is a rationalisation of what the Indian treatise Manusmriti says about gender names.
Exploring a name-gender identification solution using Machine Learning, happened to recollect a verse from the Manusmriti or “Laws of Manu”, on female names:
Verse 33. The names of women should be easy to pronounce, not imply anything dreadful, possess a plain meaning, be pleasing and auspicious, end in long vowels, and contain a word of benediction: Refer to source:
From a total of 15,551 girl baby names (UK), a whopping 82.45% ends in vowel sounds !!
On the other hand, out of the 11,997 male boy first names, only 39.67% ends in vowel sounds. While the sound of the last syllable is not conclusive evidence of gender, but definitely a factor to reckon with, in identifying gender names.
The analysis has been done with English names; obviously, Asian names should fare higher in this ratio. Enough evidence to find the right weight for gender names in your ML models!!

To do a swift check with names, get the first names in the UK from the Office of the National statistics site: Baby Names.
And the ‘R’ code:
# Set the working directorysetwd("F:/GitHub/identifygender/src")wd <- getwd()# loading all required libraries through a config filesource("config/libraries.R")# Loading all helper classessource("lib/helpers.R")# Loading many csv files in one gosetwd("F:/GitHub/identifygender/src/data/femalenames")files = list.files(pattern="*.csv")# First apply read.csv, then rbindmyfiles = do.call(rbind, lapply( files, function(x) read.csv(x, stringsAsFactors = FALSE)))myfiles <- myfiles[,c("Name","Count")]# Rename columnscolnames(myfiles) <- c("givenName","gender")# Tag names as females - would want to compile male names to form one whole listmyfiles$gender <- "female"girls.ds <- unique( myfiles[ , 1:2 ] )# Strip emtpy spaces from both sidesgirls.ds$givenName <- as.vector(trimws(girls.ds$givenName, which = c("both")))# Explode the names to charactersgirls.ds$LastInit <- sapply(strsplit(as.character(girls.ds$givenName), ""), tail, 1)# Identify if the last letter is a consonent sound (note: vowel/consonent sound, not letter)girls.ds$isVowel <- gsub("[^aeiouyhrAEIOUYHR]","C",girls.ds$LastInit)# Identify if the last letter is a vowel soundgirls.ds$isVowel <- gsub("[^C]","V",girls.ds$isVowel)# Group by, to get the numbers:girls.ds %>% group_by(isVowel)%>% count(isVowel)
Gives the following output:
# A tibble: 2 x 2
# Groups: isVowel [2]
isVowel n
<chr>> <int>>
1 C 2728
2 V 12823
From a total of 15551 girl baby names, a whopping 82.45% end in vowel sounds !! The same analysis done with boy’s first names…
# A tibble: 2 x 2
# Groups: isVowel [2]
isVowel n
<chr>> <int>>
1 C 7238
2 V 4759
Of the 11997 male boy first names, only 39.67% end in vowel sounds. While the last initial is not a conclusive evidence of gender, the ending sound of a name is a factor to reckon with, in name gender analysis.
Specifically, on solutions for name-gender identification using ML…
There are two packages available in R to help with gender identification:
- genderR (helps identify gender using historical data)
- genderizeR (There is an internal function to call a developer API) This package expects a structured dictionary to be in place with first names and probabilities.
Combining solutions from these two packages, I have put up a solution that manages most of the Western names. The dictionary is built from data available from the US census department. Due to the cosmopolitan nature of the US society
Conclusion
The conclusion from the above analysis is that in any Machine Learning model employing gender identification, this is a invaluable feature that can boost its accuracy significantly.


Leave a Reply