示例#1
0
def experiment_3():
    classifier_1  = svm.LinearSVC()
    classifier_2 = MultinomialNB()
    
    #SENTIMENT WORDS
    #dataset 1
    l_parser.parse_file(SOURCE_DATA_FILE,L_TARGET_DATA_FILE , 1)
    #dataset 2
    l_parser.parse_file(SOURCE_DATA_FILE_2,L_TARGET_DATA_FILE_2 , 1)
    
    
    l_analyzer.cross_val(L_TARGET_DATA_FILE,classifier_1)
    l_analyzer.cross_val(L_TARGET_DATA_FILE,classifier_2)
    
    l_analyzer.cross_val(L_TARGET_DATA_FILE_2,classifier_1)
    l_analyzer.cross_val(L_TARGET_DATA_FILE_2,classifier_2)
    
    #ALL WORDS
    
    l_parser.parse_file(SOURCE_DATA_FILE,L_TARGET_DATA_FILE , 2)
    l_parser.parse_file(SOURCE_DATA_FILE_2,L_TARGET_DATA_FILE_2 , 2)
    
    l_analyzer.cross_val(L_TARGET_DATA_FILE,classifier_1)
    l_analyzer.cross_val(L_TARGET_DATA_FILE,classifier_2) 
    
    l_analyzer.cross_val(L_TARGET_DATA_FILE_2,classifier_1)
    l_analyzer.cross_val(L_TARGET_DATA_FILE_2,classifier_2)
示例#2
0
import cPickle as pickle
import numpy as np

SOURCE_DATA_FILE = "../../msd_dense_subset/mood.txt"
SOURCE_DATA_FILE_2 = "../../msd_dense_subset/mood2.txt"

COMBINED_TARGET_DATA_FILE = "../../msd_dense_subset/mood.pkl"

LYRICS_TARGET_DATA_FILE = "../../msd_dense_subset/mood_lyrics_features_2.pkl"

ECHONEST_TARGET_DATA_FILE = "../../msd_dense_subset/mood_echonest_features_2.pkl"

#parse echonestfeatures
echonestparser.parse_file(SOURCE_DATA_FILE_2, ECHONEST_TARGET_DATA_FILE)
#parse lyricsfeatures
lyricsparser.parse_file(SOURCE_DATA_FILE_2,LYRICS_TARGET_DATA_FILE,1)

#get both features and combine them to a new feature space
with open(ECHONEST_TARGET_DATA_FILE, 'r') as f:
            data = pickle.load(f)
            echonest_features = data['features']
            echonest_tracks = data['tracks']
with open(LYRICS_TARGET_DATA_FILE, 'r') as f:
            data = pickle.load(f)
            labels = data['labels']
            lyrics_features = data['features']
            lyrics_tracks = data['tracks']
combined_tracks = list()
combined_features = np.empty((len(lyrics_tracks),echonest_features.shape[1]+lyrics_features.shape[1]),dtype='float')
combined_labels = list()
for i in range(len(lyrics_tracks)):