def test_dame_gender_guess_list(self):
     ds = DameSexmachine()
     self.assertEqual([
         'male', 'male', 'male', 'male', 'male', 'male', 'female', 'female',
         'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male',
         'male', 'male', 'female', 'male', 'male'
     ], ds.guess_list(path="files/names/partial.csv", binary=False))
     self.assertEqual(
         [1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1],
         ds.guess_list(path="files/names/partial.csv",
                       binary=True,
                       ml="nltk"))
예제 #2
0
 def test_dame_sexmachine_guess_list_method_returns_correct_result(self):
     ds = DameSexmachine()
     self.assertEqual(['male', 'male', 'male', 'male', 'female', 'male', 'female', 'female', 'male', 'male', 'male', 'male', 'male', 'male', 'female', 'male', 'male', 'male', 'female', 'male', 'male'], ds.guess_list(path="files/names/partial.csv", binary=False))
     self.assertEqual([1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1], ds.guess_list(path="files/names/partial.csv",binary=True))
     self.assertEqual([1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1], ds.guess_list(path="files/names/partial.csv",binary=True, ml="nltk"))
     # sgd_model = ds.sgd_load()
     # self.assertEqual([0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0], ds.guess_list(path="files/names/partial.csv",binary=True, ml="sgd"))
     svc_model = ds.svc_load()
     self.assertEqual([1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1], ds.guess_list(path="files/names/partial.csv",binary=True, ml="svc"))
예제 #3
0
parser.add_argument('--notoutput', default=False, action="store_true")
parser.add_argument('--jsonoutput',
                    type=str,
                    default="files/names/out.json",
                    required=False,
                    help="files/names/out.json")
parser.add_argument('--ml',
                    default="nltk",
                    choices=[
                        'nltk', 'svc', 'sgd', 'gaussianNB', 'multinomialNB',
                        'bernoulliNB', 'tree', 'mlp', 'adaboost'
                    ])
args = parser.parse_args()

ds = DameSexmachine()
if args.notoutput:
    gl = ds.gender_list(path=args.csv)
    sl = ds.guess_list(path=args.csv, binary=args.binary, ml=args.ml)
else:
    print("################### Dame Gender!!")
    gl = ds.gender_list(path=args.csv)
    print("Gender list: " + str(gl))
    sl = ds.guess_list(path=args.csv, binary=args.binary, ml=args.ml)
    print("Guess list:  " + str(sl))

if (args.jsonoutput == ""):
    ds.csv2json(path=args.csv, l=gl, jsonf=args.csv + ".gender.json")
    ds.csv2json(path=args.csv, l=sl, jsonf=args.csv + ".guess.json")
else:
    ds.csv2json(path=args.csv, l=sl, jsonf=args.jsonoutput)
예제 #4
0
    dgg = DameGenderGuesser()
    print("################### GenderGuesser!!")
    gl = dgg.gender_list(path=args.csv)
    print("Gender list: " + str(gl))
    sl = dgg.guess_list(path=args.csv, binary=True)
    print("Guess list:  " +str(sl))

    genderguesser_accuracy = dgg.accuracy_score_dame(gl,sl)
    print("GenderGuesser accuracy: %s" % genderguesser_accuracy)

    ds = DameSexmachine()
    print("################### Dame Gender!!")
    gl = ds.gender_list(path=args.csv)
    print("Gender list: " + str(gl))
    sl = ds.guess_list(path=args.csv, binary=True)
    print("Guess list:  " +str(sl))

    sexmachine_accuracy = ds.accuracy_score_dame(gl,sl)
    print("Sexmachine accuracy: %s" % sexmachine_accuracy)

    dga = DameGenderApi()
    print("################### GenderApi!!")
    gl = dga.gender_list(pat=args.csv)
    print("Gender list: " + str(gl))

    dna = DameNameapi()
    print("################### Nameapi!!")
    gl = dna.gender_list(path=args.csv)
    print("Gender list: " + str(gl))
    sl = dna.guess_list(path=args.csv, binary=True)
예제 #5
0
파일: errors.py 프로젝트: uritau/damegender
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--csv', default="files/names/min.csv")
parser.add_argument('--api', default="damegender", choices=['damegender', 'namsor', 'genderize', 'genderguesser', 'genderapi', 'nameapi'])
args = parser.parse_args()
#print(args.csv)




if (args.api == "damegender"):
    dn = DameSexmachine()
    print("Damegender with %s has: " % args.csv)
    gl1 = dn.gender_list(path=args.csv)
    gl2 = dn.guess_list(path=args.csv, binary=True)
    ec = dn.error_coded(gl1, gl2)
    print("+ The error code: %s" % ec)
    ecwa = dn.error_coded_without_na(gl1, gl2)
    print("+ The error code without na: %s" %  ecwa)
    naCoded = dn.na_coded(gl1, gl2)
    print("+ The na coded: %s" %  naCoded)
    egb = dn.error_gender_bias(gl1, gl2)
    print("+ The error gender bias: %s" %  egb)
elif (args.api == "genderize"):
    dn = DameGenderize()
    print("Genderize with %s has: " % args.csv)
    gl1 = dn.gender_list(path=args.csv)
    gl2 = dn.guess_list(path=args.csv, binary=True)
    ec = dn.error_coded(gl1, gl2)
    print("+ The error code: %s" % ec)