Skip to content

Commit

Permalink
Merge pull request #183 from mpharrigan/evalfile
Browse files Browse the repository at this point in the history
Add "module" estimator spec
  • Loading branch information
cxhernandez authored Jul 13, 2017
2 parents 796a7f4 + a6d55b1 commit 7caa23b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion osprey/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

FIELDS = {
'estimator': ['pickle', 'eval', 'eval_scope', 'entry_point',
'params'],
'params', 'module'],
'dataset_loader': ['name', 'params'],
'trials': ['uri', 'project_name'],
'search_space': dict,
Expand Down Expand Up @@ -151,7 +151,18 @@ def estimator(self):
pickle: path-to-pickle-file.pkl
eval: "Pipeline([('cluster': KMeans())])"
entry_point: sklearn.linear_model.LogisticRegression
module: myestimator
"""
module_path = self.get_value('estimator/module')
if module_path is not None:
with prepend_syspath(dirname(abspath(self.path))):
estimator_module = importlib.import_module(module_path)
estimator = estimator_module.estimator()
if not isinstance(estimator, sklearn.base.BaseEstimator):
raise RuntimeError('estimator/pickle must load a '
'sklearn-derived Estimator')
return estimator

evalstring = self.get_value('estimator/eval')
if evalstring is not None:
got = self.get_value('estimator/eval_scope')
Expand Down

0 comments on commit 7caa23b

Please sign in to comment.