Пример #1
0
    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)
    rg = regression_one(Xtrain, Ygtrain)
    rb = regression_one(Xtrain, Ybtrain)
    Yrpred = np.sum(Xtest * rr, axis=1)
    Ygpred = np.sum(Xtest * rg, axis=1)
    Ybpred = np.sum(Xtest * rb, axis=1)

    r_avg = average_vector_dist(Yrpred, r_dict, idstest)
    g_avg = average_vector_dist(Ygpred, g_dict, idstest)
    b_avg = average_vector_dist(Ybpred, b_dict, idstest)

    avg = (r_avg + g_avg + b_avg) / 3
    if (avg < best_avg):
        best_avg = avg
        best_r = r_avg
        best_g = g_avg
    
    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)
    rs = regression_one(Xtrain, Ystrain)
    rv = regression_one(Xtrain, Yvtrain)
    Yhpred = np.sum(Xtest * rh, axis=1)
    Yspred = np.sum(Xtest * rs, axis=1)
    Yvpred = np.sum(Xtest * rv, axis=1)
  
    h_avg = average_vector_dist(Yhpred, h_dict, idstest)
    s_avg = average_vector_dist(Yspred, s_dict, idstest)
    v_avg = average_vector_dist(Yvpred, v_dict, idstest)

    avg = (h_avg + s_avg + v_avg)/3
    if (avg < best_avg):
        best_avg = avg
        best_h = h_avg
        best_s = s_avg
    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:]
    #print Yarotest[0]

    rva = regression_one(Xtrain, Yvatrain)
    raro = regression_one(Xtrain, Yarotrain)
    
    Yvapred = np.sum(Xtest * rva, axis=1)
    Yaropred = np.sum(Xtest * raro, axis=1)
  
    va_avg = average_vector_dist(Yvapred, va_dict, idstest)
    aro_avg = average_vector_dist_polar(Yaropred, aro_dict, idstest)

    avg = (va_avg + aro_avg)/2
    if (avg < best_avg):
        best_avg = avg
        best_va = va_avg
        best_aro = aro_avg

Пример #4
0
    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)
    rs = regression_one(Xtrain, Ystrain)
    rv = regression_one(Xtrain, Yvtrain)
    Yhpred = np.sum(Xtest * rh, axis=1)
    Yspred = np.sum(Xtest * rs, axis=1)
    Yvpred = np.sum(Xtest * rv, axis=1)

    h_avg = average_vector_dist(Yhpred, h_dict, idstest)
    s_avg = average_vector_dist(Yspred, s_dict, idstest)
    v_avg = average_vector_dist(Yvpred, v_dict, idstest)

    avg = (h_avg + s_avg + v_avg) / 3
    if (avg < best_avg):
        best_avg = avg
        best_h = h_avg
        best_s = s_avg
Пример #5
0
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)
    
    Yvapred = np.sum(Xtest * rva, axis=1)
    Yaropred = np.sum(Xtest * raro, axis=1)
  
    va_avg = average_vector_dist(Yvapred, va_dict, idstest)
    aro_avg = average_vector_dist(Yaropred, aro_dict, idstest)

    avg = (va_avg + aro_avg)/2
    if (avg < best_avg):
        best_avg = avg
        best_va = va_avg
        best_aro = aro_avg

print "BEST"
    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)
    rg = regression_one(Xtrain, Ygtrain)
    rb = regression_one(Xtrain, Ybtrain)
    Yrpred = np.sum(Xtest * rr, axis=1)
    Ygpred = np.sum(Xtest * rg, axis=1)
    Ybpred = np.sum(Xtest * rb, axis=1)

  
    r_avg = average_vector_dist(Yrpred, r_dict, idstest)
    g_avg = average_vector_dist(Ygpred, g_dict, idstest)
    b_avg = average_vector_dist(Ybpred, b_dict, idstest)

    avg = (r_avg + g_avg + b_avg)/3
    if (avg < best_avg):
        best_avg = avg
        best_r = r_avg