Skip to content

Commit

Permalink
Fixed import issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mghasemi committed Feb 21, 2019
1 parent aacbd22 commit 94ce38a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions SKSurrogate/aml.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,12 @@ def Generate(self, l):


try:
from .structsearch import Real, Integer, Categorical, HDReal, BoxSample
from .structsearch import Real, Integer, Categorical, HDReal
except:
Real = lambda a, b: None
Integer = lambda a, b: None
Categorical = lambda a: None
HDReal = lambda a, b: None
BoxSample = type('BoxSample', (object,), dict(check_constraints=lambda: None, sample=lambda x: None))

default_config = {
# Classifiers
Expand Down Expand Up @@ -375,7 +374,7 @@ def types(self):
else:
self.config_types[alg] = 'transformer'

def add_surrogate(self, estimator, itrs, sampling=BoxSample, optim='L-BFGS-B'):
def add_surrogate(self, estimator, itrs, sampling=None, optim='L-BFGS-B'):
"""
Adding a regressor for surrogate optimization procedure.
Expand All @@ -387,6 +386,9 @@ def add_surrogate(self, estimator, itrs, sampling=BoxSample, optim='L-BFGS-B'):
"""
if self.surrogates is None:
self.surrogates = []
if sampling is None:
from .structsearch import BoxSample
sampling = BoxSample
self.surrogates.append((estimator, itrs, sampling, optim))

def _cast(self, n, X, y):
Expand Down
5 changes: 4 additions & 1 deletion SKSurrogate/structsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,13 @@ def __init__(self, a, b, **kwargs):

try:
from sklearn.model_selection._search import BaseSearchCV
except:
BaseSearchCV = type('BaseSearchCV', (object,), dict())

try:
from Optimithon import NumericDiff
except:
NumericDiff = type('NumericDiff', (object,), dict(Simple=lambda: 0., ))
BaseSearchCV = type('BaseSearchCV', (object,), dict())


class SurrogateRandomCV(BaseSearchCV):
Expand Down

0 comments on commit 94ce38a

Please sign in to comment.