from preProcessor import PreProcessor import argparse from regression import Regression from picDrawer import PicDrawer if __name__ == '__main__': ''' python run -f [filepath] -s [filepath] -c [stock code] output: stock error : implement by regression.score() picture : implement by drawer ''' # create pre processor data_cleaner = PreProcessor() train_feature, train_label, test_feature, test_label = data_cleaner.run() reg = Regression() reg.fit(train_feature, train_label) pred_result = reg.predict(test_feature) score = reg.score(test_label, pred_result) drawer = PicDrawer() drawer.run()
args = parser.parse_args() file_path = args.filepath train_set_choice = args.train_set code = str(args.code) method = args.method # create pre processor data_cleaner = PreProcessor(train_set_choice, code, file_path, args.ratio, args.preprocess) train_feature, train_label, test_feature, test_label, corr = data_cleaner.run( ) print test_label reg = Regression(args.method) print "training model...\n" reg.fit(train_feature, train_label) print "predicting...\n" pred_result = reg.predict(test_feature) print "scoring...\n" score = reg.score(test_label, test_feature) print "drawing...\n" drawer = PicDrawer(corr, pred_result, test_label) drawer.get_corr_map() drawer.get_validation_comparison() print("score" + str(score)) print "regressor exit!"