Tasks
The task module implements a hierarchy of explanation tasks that can be used to explain HPO.
The tasks provide a convenient API to construct surrogate models from different data sources (pretrained estimators, empirical data, or a black box function) and to add domain specific information such as a baseline configuration or an optimizer of interest.
AblationExplanationTask
¶
Bases: BaselineExplanationTask
Defines an ablation explanation task, comparing a configuration of interest to a baseline.
Source code in src/hypershap/task.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
__init__(config_space, surrogate_model, baseline_config, config_of_interest)
¶
Initialize an AblationExplanationTask with a baseline and a configuration of interest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
baseline_config
|
Configuration
|
The baseline configuration. |
required |
config_of_interest
|
Configuration
|
The configuration of interest. |
required |
Source code in src/hypershap/task.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
BaselineExplanationTask
¶
Bases: ExplanationTask
Defines an explanation task with a baseline configuration.
Source code in src/hypershap/task.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
__init__(config_space, surrogate_model, baseline_config)
¶
Initialize a BaselineExplanationTask with a baseline configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
baseline_config
|
Configuration
|
The baseline configuration. |
required |
Source code in src/hypershap/task.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
ExplanationTask
¶
Defines the base class for explanation tasks, providing access to the configuration space and surrogate model.
Source code in src/hypershap/task.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
__init__(config_space, surrogate_model)
¶
Initialize an ExplanationTask with a configuration space and surrogate model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space for the explanation task. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
Source code in src/hypershap/task.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
from_base_model(config_space, base_model)
staticmethod
¶
Create an ExplanationTask from a pre-trained base model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
base_model
|
BaseEstimator
|
The pre-trained base model. |
required |
Returns:
| Type | Description |
|---|---|
ExplanationTask
|
An ExplanationTask instance. |
Source code in src/hypershap/task.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
from_basemodel_multidata(config_space, base_model)
staticmethod
¶
Create an ExplanationTask from a list of datasets of different HPO tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
base_model
|
list[BaseEstimator]
|
The list of base models to be used as surrogate models. |
required |
Returns:
| Type | Description |
|---|---|
ExplanationTask
|
An ExplanationTask instance. |
Source code in src/hypershap/task.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
from_data(config_space, data, base_model=None)
staticmethod
¶
Create an ExplanationTask from a dataset of configurations and their performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
data
|
list[tuple[Configuration, float]]
|
A list of tuples, where each tuple contains a configuration and its corresponding performance. |
required |
base_model
|
BaseEstimator | None
|
The base model to use for training the surrogate model. Defaults to RandomForestRegressor. |
None
|
Returns:
| Type | Description |
|---|---|
ExplanationTask
|
An ExplanationTask instance. |
Source code in src/hypershap/task.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
from_data_multidata(config_space, data_multidata, base_model=None)
staticmethod
¶
Create an ExplanationTask from a list of datasets of different HPO tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
data_multidata
|
list[list[tuple[Configuration, float]]]
|
A list of tuples, where each tuple contains a configuration and its corresponding performance. |
required |
base_model
|
BaseEstimator | None
|
The base model to use for training the surrogate model. Defaults to RandomForestRegressor. |
None
|
Returns:
| Type | Description |
|---|---|
ExplanationTask
|
An ExplanationTask instance. |
Source code in src/hypershap/task.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
from_function(config_space, function, n_samples=1000, base_model=None, seed=0)
staticmethod
¶
Create an ExplanationTask from a function that evaluates configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
function
|
Callable[[Configuration], float]
|
A callable that takes a configuration and returns its performance. |
required |
n_samples
|
int
|
The number of configurations to sample for training the surrogate model. Defaults to 1000. |
1000
|
base_model
|
BaseEstimator | None
|
The base model to use for training the surrogate model. Defaults to RandomForestRegressor. |
None
|
seed
|
int | None
|
The seed for the random number generator, it is used to seed a deep copy of the config space. |
0
|
Returns:
| Type | Description |
|---|---|
ExplanationTask
|
An ExplanationTask instance. |
Source code in src/hypershap/task.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
from_function_multidata(config_space, functions, n_samples=1000, base_model=None)
staticmethod
¶
Create an ExplanationTask from a list of functions that evaluate configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
functions
|
list[Callable[[Configuration], float]]
|
A list of callables that take a configuration and returns its performance. |
required |
n_samples
|
int
|
The number of configurations to sample for training the surrogate model. Defaults to 1000. |
1000
|
base_model
|
BaseEstimator | None
|
The base model to be used for training the surrogate model. Defaults to RandomForestRegressor. |
None
|
Returns:
| Type | Description |
|---|---|
ExplanationTask
|
An ExplanationTask instance. |
Source code in src/hypershap/task.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
get_hyperparameter_names()
¶
Return the names of the hyperparameters in the configuration space.
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of hyperparameter names. |
Source code in src/hypershap/task.py
87 88 89 90 91 92 93 94 | |
get_num_hyperparameters()
¶
Return the number of hyperparameters in the configuration space.
Returns:
| Type | Description |
|---|---|
int
|
The number of hyperparameters. |
Source code in src/hypershap/task.py
78 79 80 81 82 83 84 85 | |
get_single_surrogate_model()
¶
Return the surrogate model for the explanation task.
Returns:
| Type | Description |
|---|---|
SurrogateModel
|
The surrogate model for the explanation task. |
Source code in src/hypershap/task.py
54 55 56 57 58 59 60 61 62 63 64 | |
get_surrogate_model_list()
¶
Return the list of surrogate models for the explanation task.
Returns:
| Type | Description |
|---|---|
list[SurrogateModel]
|
The list of surrogate models for the explanation task. |
Source code in src/hypershap/task.py
66 67 68 69 70 71 72 73 74 75 76 | |
is_multi_data()
¶
Return if the explanation task is a multi-data task.
Returns:
| Type | Description |
|---|---|
bool
|
True if the explanation task is a multi-data task. |
Source code in src/hypershap/task.py
45 46 47 48 49 50 51 52 | |
MistunabilityExplanationTask
¶
Bases: BaselineExplanationTask
Defines a mistunability explanation task.
Source code in src/hypershap/task.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
__init__(config_space, surrogate_model, baseline_config)
¶
Initialize a MistunabilityExplanationTask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
baseline_config
|
Configuration
|
The baseline configuration. |
required |
Source code in src/hypershap/task.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
MultiBaselineAblationExplanationTask
¶
Bases: MultiBaselineExplanationTask
Defines an ablation explanation task with multiple baseline configurations.
Source code in src/hypershap/task.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
__init__(config_space, surrogate_model, baseline_configs, config_of_interest)
¶
Initialize an MultiBaselineAblationExplanationTask with a list of baseline configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
baseline_configs
|
list[Configuration]
|
The baseline configurations. |
required |
config_of_interest
|
Configuration
|
The configuration of interest. |
required |
Source code in src/hypershap/task.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
MultiBaselineExplanationTask
¶
Bases: ExplanationTask
Defines an explanation task with multiple baseline configurations.
Source code in src/hypershap/task.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
__init__(config_space, surrogate_model, baseline_configs)
¶
Initialize a MultiBaselineExplanationTask with a list of baseline configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
baseline_configs
|
list[Configuration]
|
A list of baseline configurations. |
required |
Source code in src/hypershap/task.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
OptimizerBiasExplanationTask
¶
Bases: ExplanationTask
Defines an optimizer bias explanation task.
Source code in src/hypershap/task.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
__init__(config_space, surrogate_model, optimizer_of_interest, optimizer_ensemble)
¶
Initialize an OptimizerBiasExplanationTask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
optimizer_of_interest
|
ConfigSpaceSearcher
|
The optimizer of interest. |
required |
optimizer_ensemble
|
list[ConfigSpaceSearcher]
|
The ensemble of optimizers. |
required |
Source code in src/hypershap/task.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
SensitivityExplanationTask
¶
Bases: BaselineExplanationTask
Defines a sensitivity explanation task.
Source code in src/hypershap/task.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
__init__(config_space, surrogate_model, baseline_config)
¶
Initialize a SensitivityExplanationTask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
baseline_config
|
Configuration
|
The baseline configuration. |
required |
Source code in src/hypershap/task.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
TunabilityExplanationTask
¶
Bases: BaselineExplanationTask
Defines a tunability explanation task.
Source code in src/hypershap/task.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
__init__(config_space, surrogate_model, baseline_config)
¶
Initialize a TunabilityExplanationTask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_space
|
ConfigurationSpace
|
The configuration space. |
required |
surrogate_model
|
SurrogateModel | list[SurrogateModel]
|
The (list of) surrogate model(s) used for the explanation task. |
required |
baseline_config
|
Configuration
|
The baseline configuration. |
required |
Source code in src/hypershap/task.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |