model.model.fit(x_train, y_train) y_pred = model.model.predict(x_test) prev_prices, prices, pred = x_test[:, -1], y_test, y_pred.reshape( y_pred.shape[0]) if e % 100 == 0: for mode, action_labels in modes.items(): trader = Trader(mode) strategy = trader.to_strategy(prev_prices, pred) optimal = trader.to_strategy(prev_prices, prices) trader.run(strategy, prices, grapher=grapher) # f.write('{} accuracy_score={} balanced_accuracy_score={} average_precision_score={} f1_score={}\n'.format( # e, # accuracy_score(strategy, optimal), # balanced_accuracy_score(strategy, optimal), # average_precision_score(strategy, optimal), # f1_score(strategy, optimal))) grapher.action_labels = action_labels grapher.pred = pred[:-1] grapher.show(action_labels=action_labels, ep=e, span=span, w=window, mode=trader.mode) grapher.reset()