Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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)

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