network.strong_train(train_x, train_y) network.save('strongtrain_test.h5') else: network.train(train_x, train_y) network.save(lstm_conf['save_file_name']) # step 5: Predict train_pred = network.predict(train_x) test_pred = network.predict(test_x) # step 6: Evaluate evaluator = Evaluator() print('simple evaluation') # method1 acc = evaluator.evaluate_trend_simple(y_true=train_y, y_pred=train_pred) print(acc) acc = evaluator.evaluate_trend_simple(y_true=test_y, y_pred=test_pred) print(acc) # method 2 acc_train_list = evaluator.evaluate_divided_trend(train_y, train_pred) acc_test_list = evaluator.evaluate_divided_trend(test_y, test_pred) print('acc_train_list = ' + str(acc_train_list)) print('acc_test_list = ' + str(acc_test_list)) # step 7: Plot train_mid_price = mid_price[0:train_size] test_mid_price = mid_price[train_size:len(mid_price)] ''' plt.figure(figsize=(200, 15))
clf.fit(train_x, train_y) clf.save_model('xgboost.m') else: clf.load_model('xgboost.m') train_pred = clf.predict(train_x) test_pred = clf.predict(test_x) show_feature_importance(clf, conf['feature_name']) # plot_scatter(test_y, test_pred) plot_classification(test_y, test_pred) evaluator = Evaluator() print('evaluate trend') acc = evaluator.evaluate_trend(train_y, train_pred) print(acc) acc = evaluator.evaluate_trend(test_y, test_pred) print(acc) print('evaluate trend without stay') acc = evaluator.evaluate_trend_2(train_y, train_pred) print(acc) acc = evaluator.evaluate_trend_2(test_y, test_pred) print(acc) print('simple evaluate') acc = evaluator.evaluate_trend_simple(train_y, train_pred) print(acc) acc = evaluator.evaluate_trend_simple(test_y, test_pred) print(acc)