Last active
May 25, 2019 01:00
-
-
Save jaikumarm/bca0e895ca19267d14d6ade194394191 to your computer and use it in GitHub Desktop.
generate_trials_to_calculate.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{'par1': 5.0, 'par2': 50.0, 'par3': 3.0} \n", | |
"{'par1': 6.0, 'par2': 51.0, 'par3': 4.0} \n", | |
"{'par1': 6.0, 'par2': 29.0, 'par3': 8.0} \n", | |
"{'par1': 5.0, 'par2': 44.0, 'par3': 5.0} \n", | |
"{'par1': 5.0, 'par2': 54.0, 'par3': 8.0} \n", | |
"{'par1': 2.0, 'par2': 14.0, 'par3': 7.0} \n", | |
"{'par1': 9.0, 'par2': 67.0, 'par3': 2.0} \n", | |
"100%|██████████| 7/7 [00:00<00:00, 53.12it/s, best loss: 2.0]\n" | |
] | |
} | |
], | |
"source": [ | |
"from hyperopt import Trials, Domain, hp, tpe, fmin\n", | |
"from hyperopt.fmin import generate_trials_to_calculate\n", | |
"\n", | |
"\n", | |
"spaceVar = {'par1' : hp.quniform('par1', 1, 9, 1),\n", | |
" 'par2' : hp.quniform('par2', 1, 100, 1),\n", | |
" 'par3' : hp.quniform('par3', 2, 9, 1)}\n", | |
"\n", | |
"def objective(space):\n", | |
" print (space)\n", | |
" return int(space['par1'])\n", | |
"\n", | |
"trials = generate_trials_to_calculate([{'par1' : 5, 'par2' : 50, 'par3' : 3}, {'par1' : 6, 'par2' : 51, 'par3' : 4}])\n", | |
"best = fmin(fn=objective, space=spaceVar, trials=trials, algo=tpe.suggest, max_evals=5)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment