|
6 | 6 | from typing import Any, Dict, List, Optional, Union
|
7 | 7 |
|
8 | 8 | import dask.distributed
|
| 9 | +import scipy.sparse |
9 | 10 |
|
10 | 11 | from ConfigSpace import Configuration
|
11 | 12 | import numpy as np
|
@@ -92,9 +93,14 @@ def __call__(
|
92 | 93 |
|
93 | 94 | scenario = Scenario(scenario_dict)
|
94 | 95 |
|
95 |
| - initial_configurations = [ |
96 |
| - Configuration(configuration_space=scenario.cs, values=member) |
97 |
| - for member in self.portfolio.values()] |
| 96 | + initial_configurations = [] |
| 97 | + for member in self.portfolio.values(): |
| 98 | + try: |
| 99 | + initial_configurations.append( |
| 100 | + Configuration(configuration_space=scenario.cs, values=member) |
| 101 | + ) |
| 102 | + except ValueError: |
| 103 | + pass |
98 | 104 |
|
99 | 105 | rh2EPM = RunHistory2EPM4LogCost
|
100 | 106 | return SMAC4AC(
|
@@ -134,9 +140,15 @@ def __call__(
|
134 | 140 | from smac.scenario.scenario import Scenario
|
135 | 141 |
|
136 | 142 | scenario = Scenario(scenario_dict)
|
137 |
| - initial_configurations = [ |
138 |
| - Configuration(configuration_space=scenario.cs, values=member) |
139 |
| - for member in self.portfolio.values()] |
| 143 | + |
| 144 | + initial_configurations = [] |
| 145 | + for member in self.portfolio.values(): |
| 146 | + try: |
| 147 | + initial_configurations.append( |
| 148 | + Configuration(configuration_space=scenario.cs, values=member) |
| 149 | + ) |
| 150 | + except ValueError: |
| 151 | + pass |
140 | 152 |
|
141 | 153 | rh2EPM = RunHistory2EPM4LogCost
|
142 | 154 | ta_kwargs['budget_type'] = self.budget_type
|
@@ -341,6 +353,25 @@ def fit(self, X, y,
|
341 | 353 | feat_type=None,
|
342 | 354 | dataset_name=None):
|
343 | 355 |
|
| 356 | + # TODO |
| 357 | + # regularly check https://github.com/scikit-learn/scikit-learn/issues/15336 whether |
| 358 | + # histogram gradient boosting in scikit-learn finally support sparse data |
| 359 | + is_sparse = scipy.sparse.issparse(X) |
| 360 | + if is_sparse: |
| 361 | + include_estimators = [ |
| 362 | + 'extra_trees', 'passive_aggressive', 'random_forest', 'sgd', 'mlp', |
| 363 | + ] |
| 364 | + else: |
| 365 | + include_estimators = [ |
| 366 | + 'extra_trees', |
| 367 | + 'passive_aggressive', |
| 368 | + 'random_forest', |
| 369 | + 'sgd', |
| 370 | + 'gradient_boosting', |
| 371 | + 'mlp', |
| 372 | + ] |
| 373 | + self.include['classifier'] = include_estimators |
| 374 | + |
344 | 375 | if self.metric is None:
|
345 | 376 | if len(y.shape) == 1 or y.shape[1] == 1:
|
346 | 377 | self.metric = accuracy
|
|
0 commit comments