コード例 #1
0
	# calculating features for whole dataset

	#print all_feat.shape

	# use regresion function to calculate v and a
    all_val = np.sum(np.array(test_feat) * X_v, axis=1)
    all_aro = np.sum(test_feat * X_a, axis=1)

	#print all_val.shape
	#print all_aro.shape

    print "ATTEMPT" + str(i)
    avg = average_distance_va(all_val, all_aro, valence, arousal, all_ids)
    nearest = nearest_dist_average_va(all_val, all_aro, valence, arousal, all_ids)
    standdev = no_stdev_average_va(all_val, all_aro, val_mean, aro_mean, valence, arousal, all_ids)

    valence_dist = valence_distance_va(all_val, all_aro, valence, arousal, all_ids)
    arousal_dist = arousal_distance_va(all_val, all_aro, valence, arousal, all_ids)

    print 'Average distance: ' + str(avg) 
    print 'Nearest distance: ' + str(nearest) 
    print 'Nearest distance: ' + str(standdev) 

    if avg < best_avg:
        best_avg = avg
        best_near = nearest
        best_std = standdev

    if best_val > valence_dist:
        best_val = valence_dist
コード例 #2
0
    # calculating features for whole dataset

    #print all_feat.shape

    # use regresion function to calculate v and a
    all_val = np.sum(np.array(test_feat) * X_v, axis=1)
    all_aro = np.sum(test_feat * X_a, axis=1)

    #print all_val.shape
    #print all_aro.shape

    print "ATTEMPT" + str(i)
    avg = average_distance_va(all_val, all_aro, valence, arousal, all_ids)
    nearest = nearest_dist_average_va(all_val, all_aro, valence, arousal,
                                      all_ids)
    standdev = no_stdev_average_va(all_val, all_aro, val_mean, aro_mean,
                                   valence, arousal, all_ids)

    valence_dist = valence_distance_va(all_val, all_aro, valence, arousal,
                                       all_ids)
    arousal_dist = arousal_distance_va(all_val, all_aro, valence, arousal,
                                       all_ids)

    print 'Average distance: ' + str(avg)
    print 'Nearest distance: ' + str(nearest)
    print 'Nearest distance: ' + str(standdev)

    if avg < best_avg:
        best_avg = avg
        best_near = nearest
        best_std = standdev
コード例 #3
0
train_ids = ids
random.shuffle(train_ids)
all_ids = train_ids[141:]
train_ids = train_ids[0:140]


# calcultae valence and arousal find_a_v_mens
val_mean, aro_mean = find_a_v_mens_va(train_ids, valence, arousal)
train_feat = find_in_dict(feat, train_ids)
test_feat = find_in_dict(feat, all_ids)

# use regression
X_v, X_a = regression(train_feat, val_mean, aro_mean)

# calculating features for whole dataset

#print all_feat.shape

# use regresion function to calculate v and a
all_val = np.sum(np.array(test_feat) * X_v, axis=1)
all_aro = np.sum(test_feat * X_a, axis=1)

#print all_val.shape
#print all_aro.shape

#plot_all_va(all_val, all_aro, all_ids, valence, arousal)

print 'Average distance: ' + str(average_distance_va(all_val, all_aro, valence, arousal, all_ids)) 
print 'Nearest distance: ' + str(nearest_dist_average_va(all_val, all_aro, valence, arousal, all_ids)) 
print 'Std distance: ' + str(no_stdev_average_va(all_val, all_aro, val_mean, aro_mean, valence, arousal, all_ids))