Make readable hyperopt best parameters result

This commit is contained in:
Gerald Lonlas
2018-01-06 17:12:32 -08:00
parent 2432c9f290
commit b3ea0f4ec5
3 changed files with 85 additions and 23 deletions

View File

@@ -8,7 +8,7 @@ from functools import reduce
from math import exp
from operator import itemgetter
from hyperopt import fmin, tpe, hp, Trials, STATUS_OK, STATUS_FAIL
from hyperopt import fmin, tpe, hp, Trials, STATUS_OK, STATUS_FAIL, space_eval
from hyperopt.mongoexp import MongoTrials
from pandas import DataFrame
@@ -209,7 +209,7 @@ def buy_strategy_generator(params):
def start(args):
global TOTAL_TRIES, PROCESSED
global TOTAL_TRIES, PROCESSED, SPACE
TOTAL_TRIES = args.epochs
exchange._API = Bittrex({'key': '', 'secret': ''})
@@ -236,6 +236,11 @@ def start(args):
trials = Trials()
best = fmin(fn=optimizer, space=SPACE, algo=tpe.suggest, max_evals=TOTAL_TRIES, trials=trials)
# Improve best parameter logging display
if best:
best = space_eval(SPACE, best)
logger.info('Best parameters:\n%s', json.dumps(best, indent=4))
results = sorted(trials.results, key=itemgetter('loss'))