Beispiel #1
0
 def test_sexmachine_gender_list_method_returns_correct_result(self):
     s = DameSexmachine()
     gl = s.gender_list()
     self.assertEqual(gl, [1, 1, 1, 1, 2, 1, 0, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1])
     self.assertEqual(len(gl), 21)
     self.assertEqual(s.females, 3)
     self.assertEqual(s.males, 16)
     self.assertEqual(s.unknown, 2)
 def test_sexmachine_gender_list(self):
     s = DameSexmachine()
     gl = s.gender_list(path="files/names/partial.csv")
     self.assertEqual(
         gl,
         [1, 1, 1, 1, 2, 1, 0, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1])
     self.assertEqual(len(gl), 21)
     self.assertEqual(s.females, 3)
     self.assertEqual(s.males, 16)
     self.assertEqual(s.unknown, 2)
Beispiel #3
0
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('ml',
                    choices=[
                        'nltk', 'svc', 'sgd', 'gaussianNB', 'multinomialNB',
                        'bernoulliNB', 'forest', 'tree', 'mlp'
                    ])
parser.add_argument('--noshow', dest='noshow', action='store_true')
parser.add_argument('--verbose', default=False, action="store_true")
args = parser.parse_args()

ds = DameSexmachine()
X = np.array(ds.features_list(path="files/names/allnoundefined.csv"))
y = ds.gender_list(path="files/names/allnoundefined.csv")
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)

if (args.verbose):
    print(X)
    print(y)

if (args.ml == "svc"):
    svc = SVC(random_state=42)
    svc.fit(X_train, y_train)
    svc_disp = plot_roc_curve(svc, X_test, y_test)

elif (args.ml == "forest"):
    rfc = RandomForestClassifier(n_estimators=10, random_state=42)
    rfc.fit(X_train, y_train)
    ax = plt.gca()
 def test_sexmachine_gender_list_all(self):
     s = DameSexmachine()
     gl = s.gender_list(path="files/names/all.csv")
     self.assertTrue(len(gl) > 1000)
Beispiel #5
0
 def test_sexmachine_gender_list_all_method_returns_correct_result(self):
     s = DameSexmachine()
     gl = s.gender_list(path="files/names/all.csv")
     self.assertTrue(len(gl) > 1000)
Beispiel #6
0
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with GNU Emacs; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA,

from app.dame_sexmachine import DameSexmachine
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("file", help="csv file")
parser.add_argument('--version', action='version', version='0.1')
args = parser.parse_args()
if (len(sys.argv) > 1):
    s = DameSexmachine()
    if (args.file == 'files/partial.csv'):
        s.gender_list()
    elif (args.file == 'files/all.csv'):
        s.gender_list(all=True)
    else:
        print("Perhaps this file has not the right format")
    print("The number of males in %s is %s" % (str(args.file), str(s.males)))
    print("The number of females in %s is %s" %
          (str(args.file), str(s.females)))
    print("The number of gender not recognised in %s is %s" %
          (str(args.file), str(s.unknown)))
Beispiel #7
0
    genderize_accuracy = dg.accuracy_score_dame(gl,sl)
    print("Genderize accuracy: %s" % genderize_accuracy)

    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)
Beispiel #8
0
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with Damegender; see the file LICENSE.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA,

from app.dame_sexmachine import DameSexmachine
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("path", help="csv file")
parser.add_argument('--version', action='version', version='0.1')
args = parser.parse_args()
if (len(sys.argv) > 1):
    s = DameSexmachine()
    if ((args.path == 'files/names/partial.csv')
            or (args.path == 'files/names/all.csv')):
        s.gender_list(args.path)
    else:
        print("Perhaps this file has not the right format")
    print("The number of males in %s is %s" % (str(args.path), str(s.males)))
    print("The number of females in %s is %s" %
          (str(args.path), str(s.females)))
    print("The number of gender not recognised in %s is %s" %
          (str(args.path), str(s.unknown)))
Beispiel #9
0

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)