Neps random search
This module implements a simple random search optimizer for a NePS pipeline. It samples configurations randomly from the pipeline's domain and environment values.
NePSComplexRandomSearch
dataclass
#
NePSComplexRandomSearch(
pipeline: PipelineSpace,
ignore_fidelity: (
bool | Literal["highest_fidelity"]
) = False,
)
A complex random search optimizer for a NePS pipeline. It samples configurations randomly from the pipeline's domain and environment values, and also performs mutations and crossovers based on previous successful trials.
| PARAMETER | DESCRIPTION |
|---|---|
pipeline
|
The pipeline to optimize, which should be a Pipeline object.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the pipeline is not a Pipeline object. |
| PARAMETER | DESCRIPTION |
|---|---|
pipeline
|
The pipeline to optimize, which should be a Pipeline object.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the pipeline is not a Pipeline object. |
Source code in neps/optimizers/neps_random_search.py
__call__
#
__call__(
trials: Mapping[str, Trial],
budget_info: BudgetInfo | None,
n: int | None = None,
) -> SampledConfig | list[SampledConfig]
Sample configurations randomly from the pipeline's domain and environment values, and also perform mutations and crossovers based on previous successful trials.
| PARAMETER | DESCRIPTION |
|---|---|
trials
|
A mapping of trial IDs to Trial objects, representing previous trials. |
budget_info
|
The budget information for the optimization process.
TYPE:
|
n
|
The number of configurations to sample. If None, a single configuration will be sampled.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SampledConfig | list[SampledConfig]
|
A SampledConfig object or a list of SampledConfig objects, depending on the value of n. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the pipeline is not a Pipeline object or if the trials are not a valid mapping of trial IDs to Trial objects. |
Source code in neps/optimizers/neps_random_search.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 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 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
import_trials
#
import_trials(
external_evaluations: Sequence[
tuple[Mapping[str, Any], UserResultDict]
],
trials: Mapping[str, Trial],
) -> list[ImportedConfig]
Import external evaluations as trials.
| PARAMETER | DESCRIPTION |
|---|---|
external_evaluations
|
A sequence of tuples containing configuration dictionaries and their corresponding results. |
trials
|
A mapping of trial IDs to Trial objects, representing previous trials. |
| RETURNS | DESCRIPTION |
|---|---|
list[ImportedConfig]
|
A list of ImportedConfig objects representing the imported trials. |
Source code in neps/optimizers/neps_random_search.py
sampled_fidelity_values
#
Sample fidelity values based on the pipeline's fidelity attributes.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, float | int]
|
A dictionary mapping fidelity names to their sampled values. |
Source code in neps/optimizers/neps_random_search.py
NePSRandomSearch
dataclass
#
NePSRandomSearch(
pipeline: PipelineSpace,
use_priors: bool = False,
ignore_fidelity: (
bool | Literal["highest_fidelity"]
) = False,
)
A simple random search optimizer for a NePS pipeline. It samples configurations randomly from the pipeline's domain and environment values.
| PARAMETER | DESCRIPTION |
|---|---|
pipeline
|
The pipeline to optimize, which should be a Pipeline object.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the pipeline is not a Pipeline object. |
| PARAMETER | DESCRIPTION |
|---|---|
pipeline
|
The pipeline to optimize, which should be a Pipeline object.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the pipeline is not a Pipeline object. |
Source code in neps/optimizers/neps_random_search.py
__call__
#
__call__(
trials: Mapping[str, Trial],
budget_info: BudgetInfo | None,
n: int | None = None,
) -> SampledConfig | list[SampledConfig]
Sample configurations randomly from the pipeline's domain and environment values.
| PARAMETER | DESCRIPTION |
|---|---|
trials
|
A mapping of trial IDs to Trial objects, representing previous trials. |
budget_info
|
The budget information for the optimization process.
TYPE:
|
n
|
The number of configurations to sample. If None, a single configuration will be sampled.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SampledConfig | list[SampledConfig]
|
A SampledConfig object or a list of SampledConfig objects, depending on the value of n. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the pipeline is not a Pipeline object or if the trials are not a valid mapping of trial IDs to Trial objects. |
Source code in neps/optimizers/neps_random_search.py
import_trials
#
import_trials(
external_evaluations: Sequence[
tuple[Mapping[str, Any], UserResultDict]
],
trials: Mapping[str, Trial],
) -> list[ImportedConfig]
Import external evaluations as trials.
| PARAMETER | DESCRIPTION |
|---|---|
external_evaluations
|
A sequence of tuples containing configuration dictionaries and their corresponding results. |
trials
|
A mapping of trial IDs to Trial objects, representing previous trials. |
| RETURNS | DESCRIPTION |
|---|---|
list[ImportedConfig]
|
A list of ImportedConfig objects representing the imported trials. |
Source code in neps/optimizers/neps_random_search.py
sampled_fidelity_values
#
Sample fidelity values based on the pipeline's fidelity attributes.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
A dictionary mapping fidelity names to their sampled values. |