Esempio n. 1
0
              'Passive', 'Pstv', 'Ngtv', 'PowTot', 'Strong', 'Positiv',
              'IAV', 'Active', 'Negativ']
sentiments.reverse()
classifiers = {}

print "DB connexion"
con = None

try:
    db, usr, pwd = load_database('database.properties')
    con = psycopg2.connect(database=db, user=usr, host='localhost')

    print "Loading the Training Set"
    fe = FeatureExtractor(tokenizer, con, sentiments)
    mySet = s.load(fe, args.number_pos, args.number_pos, args.number_neut)
    training, testing = s.splitTrainingAndTestingSet(mySet, .8)

    print "Training the Models"

    # RBF: gamma varies
    classifier_rbf_gamma_01 = svm.SVC(kernel='rbf', gamma=.1)
    classifier_rbf_gamma_02 = svm.SVC(kernel='rbf', gamma=.2)
    classifier_rbf_gamma_03 = svm.SVC(kernel='rbf', gamma=.3)
    classifier_rbf_gamma_05 = svm.SVC(kernel='rbf', gamma=.5)
    classifier_rbf_gamma_08 = svm.SVC(kernel='rbf', gamma=.8)
    classifier_rbf_gamma_15 = svm.SVC(kernel='rbf', gamma=1.5)
    classifier_rbf_gamma_3 = svm.SVC(kernel='rbf', gamma=3)
    classifier_rbf_gamma_10 = svm.SVC(kernel='rbf', gamma=10)
    classifier_rbf_gamma_25 = svm.SVC(kernel='rbf', gamma=25)

    # Sigmoid
Esempio n. 2
0
              'IAV', 'Active', 'Negativ']
sentiments.reverse()
classifiers = {}

print "DB connexion"
con = None
testingSet = None

try:
    db, usr, pwd = load_database('database.properties')
    con = psycopg2.connect(database=db, user=usr, host='localhost')

    print "Loading the Testing Set"
    fe = FeatureExtractor(tokenizer, con, sentiments)
    mySet = s.load(fe, args.number_pos, args.number_pos, args.number_neut)
    testingSet, _ = s.splitTrainingAndTestingSet(mySet, 1)

    # print testingSet.X, testingSet.Y

except psycopg2.DatabaseError, e:
    print 'Error %s' % e
    sys.exit(1)

finally:
    if con:
        con.close()

# Testing the performance
# Loading the classifiers
path = args.origin_path
list_classifier_filename = os.listdir(path)