Created
May 5, 2014 16:37
-
-
Save malev/af89339e581558788f06 to your computer and use it in GitHub Desktop.
Gender detection testing app (genderPredictor)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice work...by the way from where i can get the separated male and female dataset...!