Skip to content

Commit

Permalink
Improve TSEMO categorical (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosfelt authored Dec 2, 2022
1 parent d9e1482 commit 0d0e6d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions summit/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,13 @@ def output_variables(self):
pass
return output_variables

def num_categorical_variables(self):
k = 0
for v in self.variables:
if v.variable_type == "categorical":
k += 1
return k

def get_categorical_combinations(self):
"""Get all combinations of categoricals using full factorial design
Expand Down
10 changes: 6 additions & 4 deletions summit/strategies/tsemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,17 @@ def suggest_experiments(self, num_experiments, prev_res: DataSet = None, **kwarg
# NSGAII internal optimisation on spectrally sampled functions
self.logger.info("Optimizing models using NSGAII.")

# Categorical only domain
if (self.domain.num_continuous_dimensions() == 0) and (
self.domain.num_categorical_variables() == 1
):
X, y = self._categorical_enumerate(models)
# Mixed domains
if self.categorical_combos is not None and len(self.input_columns) > 0:
elif self.categorical_combos is not None and len(self.input_columns) > 1:
X, y = self._nsga_optimize_mixed(models)
# Continous domains
elif self.categorical_combos is None and len(self.input_columns) > 0:
X, y = self._nsga_optimize(models)
# Categorical only domain
else:
X, y = self._categorical_enumerate(models)

# Return if no suggestiosn found
if X.shape[0] == 0 and y.shape[0] == 0:
Expand Down

0 comments on commit 0d0e6d9

Please sign in to comment.