Skip to content

Commit

Permalink
remove input type
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBlanke committed Dec 31, 2023
1 parent 5659988 commit 0bf4b93
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


class MachineLearningFunction(BaseTestFunction):
def __init__(self, input_type="dictionary"):
super().__init__(input_type)
def __init__(self):
super().__init__()

self.objective_function.__func__.__name__ = self.__name__

Expand Down
5 changes: 4 additions & 1 deletion surfaces/machine_learning_functions/tabular_classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class KNeighborsClassifierFunction(MachineLearningFunction):
__name__ = "k_neighbors_classifier"

def __init__(self, input_type="dictionary", sleep=0):
super().__init__(input_type, sleep)
super().__init__()

self.input_type = input_type
self.sleep = sleep

self.search_space = {
"n_neighbors": list(np.arange(3, 150)),
Expand Down
10 changes: 8 additions & 2 deletions surfaces/machine_learning_functions/tabular_regressors.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class KNeighborsRegressorFunction(MachineLearningFunction):
__name__ = "k_neighbors_regressor"

def __init__(self, input_type="dictionary", sleep=0):
super().__init__(input_type, sleep)
super().__init__()

self.input_type = input_type
self.sleep = sleep

self.search_space = {
"n_neighbors": list(np.arange(3, 150)),
Expand All @@ -37,7 +40,10 @@ class GradientBoostingRegressorFunction(MachineLearningFunction):
__name__ = "gradient_boosting_regressor"

def __init__(self, input_type="dictionary", sleep=0):
super().__init__(input_type, sleep)
super().__init__()

self.input_type = input_type
self.sleep = sleep

self.search_space = {
"n_estimators": list(np.arange(5, 150)),
Expand Down
12 changes: 6 additions & 6 deletions surfaces/mathematical_functions/_base_objective_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@ def __init__(self, metric="score", input_type="dictionary", sleep=0):
self.input_type = input_type
self.sleep = sleep

def search_space(self, min=-5, max=5, step=0.1, value_typ="array"):
def search_space(self, min=-5, max=5, step=0.1, value_types="array"):
search_space_ = {}

for dim in range(self.n_dim):
dim_str = "x" + str(dim)

values = np.arange(min, max, step)
if value_typ == "list":
if value_types == "list":
values = list(values)
search_space_[dim_str] = values

return search_space_

def collect_data(self, if_exists="append"):
self.search_space = self.search_space(value_typ="list")
self.search_space = self.search_space(value_types="list")

para_names = list(self.search_space().keys())
para_names = list(self.search_space.keys())
search_data_cols = para_names + ["score"]
search_data = pd.DataFrame([], columns=search_data_cols)
search_data_length = 0

dim_sizes_list = [len(array) for array in self.search_space().values()]
dim_sizes_list = [len(array) for array in self.search_space.values()]
search_space_size = reduce((lambda x, y: x * y), dim_sizes_list)

while search_data_length < search_space_size:
hyper = Hyperactive(verbosity=["progress_bar"])
hyper.add_search(
self.objective_function_dict,
self.search_space(value_typ="list"),
self.search_space,
initialize={},
n_iter=search_space_size,
optimizer=GridSearchOptimizer(direction="orthogonal"),
Expand Down

0 comments on commit 0bf4b93

Please sign in to comment.