NameGenderClassification
NameGenderClassification copied to clipboard
Missing data downloading
The code assumes you have downloaded and unzipped the files. Here a way to handle it
def load_data():
my_data = np.genfromtxt('yob2014.txt',
delimiter=',',
dtype=[('name','S50'), ('gender','S1'),('count','i4')],
converters={0: lambda s:s.lower()})
try:
load_data()
except IOError:
from urllib.request import urlretrieve
urlretrieve('https://www.ssa.gov/oact/babynames/names.zip', 'yob2014.zip')
from zipfile import ZipFile
with ZipFile("yob2014.zip","r") as zip_ref:
zip_ref.extractall()
load_data()