Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "module" estimator spec #183

Merged
merged 1 commit into from
Jul 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion osprey/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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 @@ -149,7 +149,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