Ejemplo n.º 1
0
r_dict, g_dict, b_dict = csv_2_dict_rgb('csv/surveydatahsv.csv')

# calculate fetures for song in train set

X = np.column_stack((va, aro))
Yr = r
Yg = g
Yb = b

best_avg = sys.maxint
best_r = sys.maxint
best_g = sys.maxint
best_b = sys.maxint

for i in range(100):
    X, Yr, Yg, Yb, ids = shufle_same(X, Yr, Yg, Yb, ids)

    trainlen = int(len(Yr) * 0.7)

    Xtrain = X[1:trainlen]
    Yrtrain = Yr[1:trainlen]
    Ygtrain = Yg[1:trainlen]
    Ybtrain = Yb[1:trainlen]

    Xtest = X[trainlen + 1:]
    Yrtest = Yr[trainlen + 1:]
    Ygtest = Yg[trainlen + 1:]
    Ybtest = Yb[trainlen + 1:]
    idstest = ids[trainlen + 1:]

    rr = regression_one(Xtrain, Yrtrain)
# print X

best_avg = sys.maxint
best_near = sys.maxint
best_std = sys.maxint

best_val = sys.maxint
best_aro = sys.maxint

print "check 3"
print X.shape
print len(Yv)
print len(Ya)

for i in range(50):
    X, Yv, Ya, all_ids = shufle_same(X, Yv, Ya, all_ids)

    print "check 4"
    print X.shape
    print len(Yv)
    print len(Ya)

    trainlen = int(len(Yv) * 0.7)

    Xtrain = X[1:trainlen]
    Yvtrain = Yv[1:trainlen]
    Yatrain = Ya[1:trainlen]

    Xtest = X[trainlen + 1:]
    Yvtest = Yv[trainlen + 1:]
    Yatest = Ya[trainlen + 1:]
print "check 3"
print X.shape
print len(Yv)
print len(Ya)

best_avg = sys.maxint
best_near = sys.maxint
best_std = sys.maxint

best_val = sys.maxint
best_aro = sys.maxint

for j in range(1, 2):
    for i in range(200):
        X, Yv, Ya, all_ids = shufle_same(X, Yv, Ya, all_ids)

        # print "check 4"
        # print X.shape
        # print len(Yv)
        # print len(Ya)

        trainlen = int(len(Yv) * 0.7)

        Xtrain = X[1:trainlen]
        Yvtrain = Yv[1:trainlen]
        Yatrain = Ya[1:trainlen]

        Xtest = X[trainlen+1:]
        Yvtest = Yv[trainlen+1:]
        Yatest = Ya[trainlen+1:]
h_dict, s_dict, v_dict = csv_2_dict_hsv('csv/surveydatahsv.csv')

# calculate fetures for song in train set

X = np.column_stack((va,aro))
Yh = h
Ys = s
Yv = v

best_avg = sys.maxint
best_h = sys.maxint
best_s = sys.maxint
best_v = sys.maxint

for i in range(100):
    X, Yh, Ys, Yv, ids = shufle_same(X, Yh, Ys, Yv, ids)   
    
    trainlen = int(len(Yh) * 0.7)

    Xtrain = X[1:trainlen]
    Yhtrain = Yh[1:trainlen]
    Ystrain = Ys[1:trainlen]
    Yvtrain = Yv[1:trainlen]

    Xtest = X[trainlen+1:]
    Yhtest = Yh[trainlen+1:]
    Ystest = Ys[trainlen+1:]
    Yvtest = Yv[trainlen+1:]
    idstest = ids[trainlen+1:]

from utils.cross_validation import cross_valid

''' 
regression tree for each response
'''


# get exsisting valence and arousal data
ids, va, aro, rows = seperate_va('csv/survery2dataMin1.csv')

while 101 in ids:
    id101 = ids.index(101)
    ids[id101:(id101+1)] = []
    va[id101:(id101+1)] = []
    aro[id101:(id101+1)] = []

va_dict, aro_dict = csv_2_dict_va('csv/survery2dataMin1.csv')

# calculate fetures for song in train set
no, feat = read_fake_chroma('features/fakechroma')
X = feature_matrix_by_id(ids, feat)
Yva = va
Yaro = aro

#for i in range(100):
X, Yva, Yaro, ids = shufle_same(X, Yva, Yaro, ids)   
    
print 'v: ' + str(cross_valid(10, X, Yva, ids, va_dict))
print 'A: ' + str(cross_valid(10, X, Yaro, ids, aro_dict))

Ejemplo n.º 6
0
h_dict, s_dict, v_dict = csv_2_dict_hsv('csv/surveydatahsv.csv')

# calculate fetures for song in train set

X = np.column_stack((va, aro))
Yh = h
Ys = s
Yv = v

best_avg = sys.maxint
best_h = sys.maxint
best_s = sys.maxint
best_v = sys.maxint

for i in range(100):
    X, Yh, Ys, Yv, ids = shufle_same(X, Yh, Ys, Yv, ids)

    trainlen = int(len(Yh) * 0.7)

    Xtrain = X[1:trainlen]
    Yhtrain = Yh[1:trainlen]
    Ystrain = Ys[1:trainlen]
    Yvtrain = Yv[1:trainlen]

    Xtest = X[trainlen + 1:]
    Yhtest = Yh[trainlen + 1:]
    Ystest = Ys[trainlen + 1:]
    Yvtest = Yv[trainlen + 1:]
    idstest = ids[trainlen + 1:]

    rh = regression_one(Xtrain, Yhtrain)
Ejemplo n.º 7
0
ids, va, aro, h, s, v= uniform_va_hsv('csv/surveydatahsv.csv')
va_dict, aro_dict = csv_2_dict_va('csv/survery2dataMin1.csv')

# calculate fetures for song in train set

X = np.column_stack((h,s,v))
Yva = va
Yaro = aro


best_avg = sys.maxint
best_aro = sys.maxint
best_va = sys.maxint

for i in range(100):
    X, Yva, Yaro, ids = shufle_same(X, Yva, Yaro, ids)   
    
    trainlen = int(len(Yaro) * 0.7)

    Xtrain = X[1:trainlen]
    Yvatrain = Yva[1:trainlen]
    Yarotrain = Yaro[1:trainlen]
    

    Xtest = X[trainlen+1:]
    Yvatest = Yva[trainlen+1:]
    Yarotest = Yaro[trainlen+1:]
    idstest = ids[trainlen+1:]

    rva = regression_one(Xtrain, Yvatrain)
    raro = regression_one(Xtrain, Yarotrain)
r_dict, g_dict, b_dict = csv_2_dict_rgb('csv/surveydatahsv.csv')

# calculate fetures for song in train set

X = np.column_stack((va,aro))
Yr = r
Yg = g
Yb = b

best_avg = sys.maxint
best_r = sys.maxint
best_g = sys.maxint
best_b = sys.maxint

for i in range(100):
    X, Yr, Yg, Yb, ids = shufle_same(X, Yr, Yg, Yb, ids)   
    
    trainlen = int(len(Yr) * 0.7)

    Xtrain = X[1:trainlen]
    Yrtrain = Yr[1:trainlen]
    Ygtrain = Yg[1:trainlen]
    Ybtrain = Yb[1:trainlen]

    Xtest = X[trainlen+1:]
    Yrtest = Yr[trainlen+1:]
    Ygtest = Yg[trainlen+1:]
    Ybtest = Yb[trainlen+1:]
    idstest = ids[trainlen+1:]
    
    rr = regression_one(Xtrain, Yrtrain)