def run(self): clean_data = CleanData() clean_data.run() calc_corr = CalcCorrMatrix() calc_corr.run() data_generator = DataGenerator() train_feature, train_label, test_feature, test_label = data_generator.run() return train_feature, train_label, test_feature, test_label
def run(self): if self.preprocess == 1: print "cleaning data...\n" clean_data = CleanData(self.file_path) clean_data.run() print "cleaning data successfully\n" print "calculating correlation matrix...\n" calc_corr = CalcCorrMatrix() corr_matrix = calc_corr.run() print "calculatE successfully\n" print "generating dataset...\n" data_generator = DataGenerator('../data/', self.code, self.ratio, corr_matrix, self.train_set_choice) train_feature, train_label, test_feature, test_label = data_generator.run( ) print "generate successfully\n" return train_feature, train_label, test_feature, test_label, corr_matrix
args = parser.parse_args() file_path = args.filepath code = str(args.code) method = args.method # create pre processor print args.preprocess if args.preprocess: data_cleaner = PreProcessor(file_path) data_cleaner.run() data_generator = DataGenerator(file_path, code, test_set_ratio=args.ratio, ahead_num=11) train_feature, train_label, test_feature, test_label = data_generator.run() reg = LearningModel(method) reg.fit(train_feature, train_label) pred_label = reg.predict(test_feature) # print type(pred_label) # print type(test_label) score = reg.score(test_feature, test_label) print score print reg.MSE(test_label, pred_label) # # score = reg.score(test_label, pred_label) # drawer = PicDrawer(file_path, code, train_label, test_label, pred_label) drawer.run()