Skip to content

Instantly share code, notes, and snippets.

@malev
Created May 5, 2014 16:37
Show Gist options
  • Save malev/af89339e581558788f06 to your computer and use it in GitHub Desktop.
Save malev/af89339e581558788f06 to your computer and use it in GitHub Desktop.
Gender detection testing app (genderPredictor)
import csv
from genderPredictor import genderPredictor
gp = genderPredictor()
gp.trainAndTest()
def gender(name):
output = 'unknown'
tmp = gp.classify(name)
if tmp == 'F':
output = 'female'
elif tmp == 'M':
output = 'male'
else:
output = 'unknown'
return output
rows = []
with open('output.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
rows.append(row)
with open('output.csv', 'w') as csvfile:
writer = csv.writer(csvfile)
for row in rows:
row.append(gender(row[0]))
writer.writerow(row)
@AkhandMishratruth
Copy link

Nice work...by the way from where i can get the separated male and female dataset...!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment