def test_dame_gender_features_list2csv(self): # TODO: You can write asserts to verify the first line g = Gender() csv1 = g.features_list2csv(path="files/names/min.csv") csv2 = g.features_list2csv(path="files/names/min.csv", categorical="categorical") csv3 = g.features_list2csv(path="files/names/min.csv", categorical="nocategorical") csv4 = g.features_list2csv(path="files/names/allnoundefined.csv", categorical="noundefined") self.assertTrue(os.path.isfile("files/features_list.csv")) file = open("files/features_list.csv", "r") if (file): self.assertTrue(os.path.isfile("files/features_list_cat.csv")) self.assertTrue(os.path.isfile("files/features_list_no_cat.csv")) self.assertTrue( os.path.isfile("files/features_list_no_undefined.csv"))
from app.dame_sexmachine import DameSexmachine from app.dame_gender import Gender ## PARAMETERS parser = argparse.ArgumentParser() parser.add_argument("--categorical", default="both", choices=['both', 'noletters', 'nocategorical', 'all']) parser.add_argument("--components", default=0, type=int) args = parser.parse_args() if (args.components > 0): ## LOAD DATASET g = Gender() if (args.categorical == "both"): g.features_list2csv(categorical="both", path="files/names/allnoundefined.csv") features = "files/features_list_no_undefined.csv" elif (args.categorical == "noletters"): g.features_list2csv(categorical="noletters", path="files/names/allnoundefined.csv") features = "files/features_list_cat.csv" elif (args.categorical == "nocategorical"): g.features_list2csv(categorical="nocategorical", path="files/names/allnoundefined.csv") features = "files/features_list_no_cat.csv" else: g.features_list2csv(categorical="both", path="files/names/all.csv") features = "files/features_list.csv" ## STEP1: N COMPONENTS + 1 TARGET x = pd.read_csv(features) #print(x.columns)
# Boston, MA 02110-1301 USA, import numpy as np import pandas as pd import matplotlib.pyplot as plt from app.dame_gender import Gender import argparse parser = argparse.ArgumentParser() parser.add_argument('--csv') args = parser.parse_args() g = Gender() if (args.csv == 'nocategorical'): g.features_list_no_categorical("files/names/all.csv") g.features_list2csv(csv="nocategorical") data = pd.read_csv('files/features_list_no_cat.csv', index_col=0) elif (args.csv == 'categorical'): g.features_list_categorical("files/names/all.csv") g.features_list2csv(csv="categorical") data = pd.read_csv('files/features_list_cat.csv', index_col=0) else: g.features_list2csv("files/names/all.csv") data = pd.read_csv('files/features_list.csv', index_col=0) #data = pd.read_csv('files/features_list_cat.csv', index_col=0) #data = pd.read_csv('files/features_list.csv', index_col=0) corr = data.corr() fig = plt.figure() ax = fig.add_subplot(111) cax = ax.matshow(corr, cmap='coolwarm', vmin=-1, vmax=1)