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

best_val = sys.maxint
best_aro = sys.maxint

for i in range(50):
    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(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 linera 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
best_std = sys.maxint

best_val = sys.maxint
best_aro = sys.maxint

for i in range(50):

    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