if __name__ == '__main__': ''' Read music data. ''' print "Loading data." #music_train = MusicData("resources/YearPredictionMSD_samples_train.txt") #music_test = MusicData("resources/YearPredictionMSD_samples_test.txt") music_train = MusicData("resources/YearPredictionMSD_train.txt") music_validation = MusicData("resources/YearPredictionMSD_validation.txt") music_test = MusicData("resources/YearPredictionMSD_test.txt") max_degree = 3 # Add polynomial features. print "Adding polynomial features." music_train.add_features(max_degree) music_test.add_features(max_degree) music_validation.add_features(max_degree) ## Normalize data. print "Normalize data." #music_train.X = z_norm(music_train.X) #music_validation.X = z_norm(music_validation.X) #music_test.X = z_norm(music_test.X) #music_train.X, mean_X, std_X = z_norm_by_feature(music_train.X) #music_validation.X = z_norm_by_feature(music_validation.X, mean_X, std_X) #music_test.X = z_norm_by_feature(music_test.X, mean_X, std_X) # Balacing train data. print "Balacing train data."
from music_data import MusicData from normal_equation import solve_normal_equation from normalize import z_norm, z_norm_by_feature import numpy as np if __name__ == '__main__': ''' Read music data. ''' print "Loading data." music_train = MusicData("resources/YearPredictionMSD_train.txt") music_validation = MusicData("resources/YearPredictionMSD_validation.txt") music_test = MusicData("resources/YearPredictionMSD_test.txt") music_train.add_features(3) music_test.add_features(3) music_validation.add_features(3) # Normalize data. print "Normalize data." # music_train.X = z_norm(music_train.X) # music_validation.X = z_norm(music_validation.X) # music_test.X = z_norm(music_test.X) music_train.X, mean_X, std_X = z_norm_by_feature(music_train.X) music_validation.X = z_norm_by_feature(music_validation.X, mean_X, std_X) music_test.X = z_norm_by_feature(music_test.X, mean_X, std_X) #music_validation = MusicData("resources/YearPredictionMSD_validation.txt") #music_test = MusicData("resources/YearPredictionMSD_test.txt")