Skip to content

Commit

Permalink
Fix skopt (#31)
Browse files Browse the repository at this point in the history
* fixed hyperopt2skopt

* updated optuna convert
  • Loading branch information
jakubczakon authored Apr 15, 2019
1 parent d95c3a3 commit 82f9644
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# The short X.Y version
version = '0.4'
# The full version, including alpha/beta/rc tags
release = '0.4.0'
release = '0.4.1'

# -- General configuration ---------------------------------------------------

Expand Down
6 changes: 4 additions & 2 deletions neptunecontrib/hpo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#

import numpy as np
import pandas as pd
from scipy.optimize import OptimizeResult
import skopt
Expand Down Expand Up @@ -64,7 +65,7 @@ def hyperopt2skopt(trials, space):
results_.setdefault('x_iters', []).append(trial_params)
results_.setdefault('func_vals', []).append(trial['result']['loss'])
optimize_results = OptimizeResult()
optimize_results.x = list(trials.argmin.values())
optimize_results.x = [trials.argmin[name] for name in param_names]
optimize_results.x_iters = results_['x_iters']
optimize_results.fun = trials.best_trial['result']['loss']
optimize_results.func_vals = results_['func_vals']
Expand Down Expand Up @@ -152,7 +153,7 @@ def optuna2skopt(results):
"""

results_ = results['params']
results_['target'] = -1.0 * results['value']
results_['target'] = results['value']
return df2result(results_,
metric_col='target',
param_cols=[col for col in results_.columns if col != 'target'])
Expand Down Expand Up @@ -231,6 +232,7 @@ def _convert_space_hop_skopt(space):
elif method == 'uniform':
dimensions.append(skopt.space.Real(low, high, name=name, prior='uniform'))
elif method == 'loguniform':
low, high = np.exp(low), np.exp(high)
dimensions.append(skopt.space.Real(low, high, name=name, prior='log-uniform'))
else:
raise NotImplementedError
Expand Down
4 changes: 2 additions & 2 deletions neptunecontrib/monitoring/skopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def send_runs(results, experiment=None):

_exp = experiment if experiment else neptune

for loss, params in zip(results.func_vals, results.x_iters):
_exp.send_metric('run_score', y=loss)
for i, (loss, params) in enumerate(zip(results.func_vals, results.x_iters)):
_exp.send_metric('run_score', x=i, y=loss)

named_params = _format_to_named_params(params, results)
_exp.send_text('run_parameters', str(named_params))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def main():
requirements = [r.strip() for r in f]
setup(
name='neptune-contrib',
version='0.4.0',
version='0.4.1',
description='Neptune Python library contributions',
author='neptune.ml',
author_email='[email protected]',
Expand Down

0 comments on commit 82f9644

Please sign in to comment.