Domain
constraints
Constraints
Bases: BaseModel
, Generic[C]
Source code in bofire/data_models/domain/constraints.py
19 20 21 22 23 24 25 26 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 |
|
__call__(experiments)
Numerically evaluate all constraints
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
data to evaluate the constraint on |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Constraint evaluation for each of the constraints |
Source code in bofire/data_models/domain/constraints.py
43 44 45 46 47 48 49 50 51 52 53 |
|
get(includes=Constraint, excludes=None, exact=False)
Get constraints of the domain
Parameters:
Name | Type | Description | Default |
---|---|---|---|
includes
|
Union[Type[CIncludes], Sequence[Type[CIncludes]]]
|
Constraint class or list of specific constraint classes to be returned. Defaults to Constraint. |
Constraint
|
excludes
|
Optional[Union[Type[CExcludes], List[Type[CExcludes]]]]
|
Constraint class or list of specific constraint classes to be excluded from the return. Defaults to None. |
None
|
exact
|
bool
|
Boolean to distinguish if only the exact class listed in includes and no subclasses inherenting from this class shall be returned. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
Constraints |
Constraints[CIncludes]
|
constraints in the domain fitting to the passed requirements. |
Source code in bofire/data_models/domain/constraints.py
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 |
|
get_reps_df()
Provides a tabular overwiev of all constraints within the domain
Returns:
Type | Description |
---|---|
pd.DataFrame: DataFrame listing all constraints of the domain with a description |
Source code in bofire/data_models/domain/constraints.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
is_fulfilled(experiments, tol=1e-06)
Check if all constraints are fulfilled on all rows of the provided dataframe
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe with data, the constraint validity should be tested on |
required |
tol
|
float
|
tolerance parameter. A constraint is considered as not fulfilled if the violation is larger than tol. Defaults to 0. |
1e-06
|
Returns:
Name | Type | Description |
---|---|---|
Boolean |
Series
|
True if all constraints are fulfilled for all rows, false if not |
Source code in bofire/data_models/domain/constraints.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
jacobian(experiments)
Numerically evaluate the jacobians of all constraints
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
data to evaluate the constraint jacobians on |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list containing the jacobians as pd.DataFrames |
Source code in bofire/data_models/domain/constraints.py
55 56 57 58 59 60 61 62 63 64 65 |
|
domain
Domain
Bases: BaseModel
Source code in bofire/data_models/domain/domain.py
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 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 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 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
|
candidate_column_names
property
The columns in the candidate dataframe
Returns:
Type | Description |
---|---|
List[str]: List of columns in the candidate dataframe (input feature keys + input feature keys_pred, input feature keys_sd, input feature keys_des) |
constraints = Field(default_factory=lambda: Constraints())
class-attribute
instance-attribute
experiment_column_names
property
The columns in the experimental dataframe
Returns:
Type | Description |
---|---|
List[str]: List of columns in the experiment dataframe (output feature keys + valid_output feature keys) |
aggregate_by_duplicates(experiments, prec, delimiter='-', method='mean')
Aggregate the dataframe by duplicate experiments
Duplicates are identified based on the experiments with the same input features. Continuous input features are rounded before identifying the duplicates. Aggregation is performed by taking the average of the involved output features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe containing experimental data |
required |
prec
|
int
|
Precision of the rounding of the continuous input features |
required |
delimiter
|
str
|
Delimiter used when combining the orig. labcodes to a new one. Defaults to "-". |
'-'
|
method
|
Literal['mean', 'median']
|
Which aggregation method to use. Defaults to "mean". |
'mean'
|
Returns:
Type | Description |
---|---|
Tuple[DataFrame, list]
|
Tuple[pd.DataFrame, list]: Dataframe holding the aggregated experiments, list of lists holding the labcodes of the duplicates |
Source code in bofire/data_models/domain/domain.py
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 |
|
coerce_invalids(experiments)
Coerces all invalid output measurements to np.nan
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe containing experimental data |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: coerced dataframe |
Source code in bofire/data_models/domain/domain.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
describe_experiments(experiments)
Method to get a tabular overview of how many measurements and how many valid entries are included in the input data for each output feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe with experimental data |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Dataframe with counts how many measurements and how many valid entries are included in the input data for each output feature |
Source code in bofire/data_models/domain/domain.py
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 |
|
get_nchoosek_combinations(exhaustive=False)
Get all possible NChooseK combinations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exhaustive
|
bool
|
if True all combinations are returned. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
Tuple |
(used_features_list, unused_features_list)
|
used_features_list is a list of lists containing features used in each NChooseK combination. unused_features_list is a list of lists containing features unused in each NChooseK combination. |
Source code in bofire/data_models/domain/domain.py
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 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
is_fulfilled(experiments, tol=1e-06, exlude_interpoint=True)
Check if all constraints are fulfilled on all rows of the provided dataframe both constraints and inputs are checked.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe with data, the constraint validity should be tested on |
required |
tol
|
float
|
Tolerance for checking the constraints. Defaults to 1e-6. |
1e-06
|
exlude_interpoint
|
bool
|
If True, InterpointConstraints are excluded from the check. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
Series
|
Boolean series indicating if all constraints are fulfilled for all rows. |
Source code in bofire/data_models/domain/domain.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
validate_candidates(candidates, only_inputs=False, tol=1e-05, raise_validation_error=True)
Method to check the validty of proposed candidates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
candidates
|
DataFrame
|
Dataframe with suggested new experiments (candidates) |
required |
only_inputs
|
(bool, optional)
|
If True, only the input columns are validated. Defaults to False. |
False
|
tol
|
(float, optional)
|
tolerance parameter for constraints. A constraint is considered as not fulfilled if the violation is larger than tol. Defaults to 1e-6. |
1e-05
|
raise_validation_error
|
bool
|
If true an error will be raised if candidates violate constraints, otherwise only a warning will be displayed. Defaults to True. |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
when a column is missing for a defined input feature |
ValueError
|
when a column is missing for a defined output feature |
ValueError
|
when a non-numerical value is proposed |
ValueError
|
when an additional column is found |
ConstraintNotFulfilledError
|
when the constraints are not fulfilled and |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: dataframe with suggested experiments (candidates) |
Source code in bofire/data_models/domain/domain.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
|
validate_constraints()
Validate that the constraints defined in the domain fit to the input features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v
|
List[Constraint]
|
List of constraints or empty if no constraints are defined |
required |
values
|
List[Input]
|
List of input features of the domain |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Feature key in constraint is unknown. |
Returns:
Type | Description |
---|---|
List[Constraint]: List of constraints defined for the domain |
Source code in bofire/data_models/domain/domain.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
validate_experiments(experiments, strict=False)
Checks the experimental data on validity
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe with experimental data |
required |
strict
|
bool
|
Boolean to distinguish if the occurrence of fixed features in the dataset should be considered or not. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
empty dataframe |
ValueError
|
the column for a specific feature is missing the provided data |
ValueError
|
there are labcodes with null value |
ValueError
|
there are labcodes with nan value |
ValueError
|
labcodes are not unique |
ValueError
|
the provided columns do no match to the defined domain |
ValueError
|
the provided columns do no match to the defined domain |
ValueError
|
Input with null values |
ValueError
|
Input with nan values |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: The provided dataframe with experimental data |
Source code in bofire/data_models/domain/domain.py
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 |
|
validate_unique_feature_keys()
Validates if provided input and output feature keys are unique
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v
|
Outputs
|
List of all output features of the domain. |
required |
value
|
Dict[str, Inputs]
|
Dict containing a list of input features as single entry. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Feature keys are not unique. |
Returns:
Name | Type | Description |
---|---|---|
Outputs |
Keeps output features as given. |
Source code in bofire/data_models/domain/domain.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
features
Inputs
Bases: _BaseFeatures[AnyInput]
Container of input features, only input features are allowed.
Attributes:
Name | Type | Description |
---|---|---|
features |
List(Inputs
|
list of the features. |
Source code in bofire/data_models/domain/features.py
242 243 244 245 246 247 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 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
|
get_bounds(specs, experiments=None, reference_experiment=None)
Returns the boundaries of the optimization problem based on the transformations
defined in the specs
dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
specs
|
InputTransformSpecs
|
Dictionary specifying which input feature is transformed by which encoder. |
required |
experiments
|
Optional[DataFrame]
|
Dataframe with input features. If provided the real feature bounds are returned based on both the opt. feature bounds and the extreme points in the dataframe. Defaults to None, |
None
|
reference_experiment
|
Optional[Serues]
|
If a reference experiment provided, |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If a feature type is not known. |
ValueError
|
If no transformation is provided for a categorical feature. |
Returns:
Type | Description |
---|---|
Tuple[List[float], List[float]]
|
Tuple[List[float], List[float]]: list with lower bounds, list with upper bounds. |
Source code in bofire/data_models/domain/features.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
get_categorical_combinations(include=Input, exclude=None)
Get a list of tuples pairing the feature keys with a list of valid categories
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include
|
Feature
|
Features to be included. Defaults to Input. |
Input
|
exclude
|
Feature
|
Features to be excluded, e.g. subclasses of the included features. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
List[(str, List[str])]: Returns a list of tuples pairing the feature keys with a list of valid categories (str) |
Source code in bofire/data_models/domain/features.py
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 |
|
get_feature_indices(specs, feature_keys)
Returns a list of indices of the given feature key list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
specs
|
InputTransformSpecs
|
Dictionary specifying which input feature is transformed by which encoder. |
required |
feature_keys
|
List[str]
|
List of feature keys. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
List[int]: The list of indices. |
Source code in bofire/data_models/domain/features.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
|
get_fixed()
Gets all features in self
that are fixed and returns them as new
Inputs
object.
Returns:
Name | Type | Description |
---|---|---|
Inputs |
Inputs
|
Input features object containing only fixed features. |
Source code in bofire/data_models/domain/features.py
265 266 267 268 269 270 271 272 273 |
|
get_free()
Gets all features in self
that are not fixed and returns them as
new Inputs
object.
Returns:
Name | Type | Description |
---|---|---|
Inputs |
Inputs
|
Input features object containing only non-fixed features. |
Source code in bofire/data_models/domain/features.py
275 276 277 278 279 280 281 282 283 |
|
inverse_transform(experiments, specs)
Transform a dataframe back to the original representations.
The original applied transformation has to be provided via the specs dictionary. Currently only input categoricals are supported.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Transformed data dataframe. |
required |
specs
|
InputTransformSpecs
|
Dictionary specifying which input feature is transformed by which encoder. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Back transformed dataframe. Only input features are included. |
Source code in bofire/data_models/domain/features.py
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
|
is_fulfilled(experiments)
Check if the provided experiments fulfill all constraints defined on the input features itself like the bounds or the allowed categories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe with input features. |
required |
Returns:
Type | Description |
---|---|
Series
|
Series with boolean values indicating if the experiments fulfill the constraints on the input features. |
Source code in bofire/data_models/domain/features.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
|
sample(n=1, method=SamplingMethodEnum.UNIFORM, seed=None)
Draw sobol samples
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
Number of samples, has to be larger than 0. Defaults to 1. |
1
|
method
|
SamplingMethodEnum
|
Method to use, implemented
methods are |
UNIFORM
|
seed
|
int
|
random seed. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Dataframe containing the samples. |
Source code in bofire/data_models/domain/features.py
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 |
|
transform(experiments, specs)
Transform a dataframe to the representation specified in specs
.
Currently only input categoricals are supported.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Data dataframe to be transformed. |
required |
specs
|
InputTransformSpecs
|
Dictionary specifying which input feature is transformed by which encoder. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Transformed dataframe. Only input features are included. |
Source code in bofire/data_models/domain/features.py
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
|
validate_candidates(candidates)
Validate a pandas dataframe with input feature values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
candidates
|
Dataframe
|
Inputs to validate. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Raises a Valueerror if a feature based validation raises an exception. |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.Dataframe: Validated dataframe |
Source code in bofire/data_models/domain/features.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
|
Outputs
Bases: _BaseFeatures[AnyOutput]
Container of output features, only output features are allowed.
Attributes:
Name | Type | Description |
---|---|---|
features |
List(Outputs
|
list of the features. |
Source code in bofire/data_models/domain/features.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
__call__(experiments, experiments_adapt=None, predictions=False)
Evaluate the objective for every feature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Experiments for which the objectives should be evaluated. |
required |
experiments_adapt
|
DataFrame
|
Experimental values
which are used to update the objective parameters on the fly.
This is for example needed when a |
None
|
predictions
|
bool
|
If True use the prediction columns in
the dataframe to calc the desirabilities |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Objective values for the experiments of interest. |
Source code in bofire/data_models/domain/features.py
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
|
add_valid_columns(experiments)
Add the valid_{feature.key}
columns to the experiments dataframe,
in case that they are not present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe holding the experiments. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Dataframe holding the experiments. |
Source code in bofire/data_models/domain/features.py
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 |
|
get_by_objective(includes=Objective, excludes=None, exact=False)
Get output features filtered by the type of the attached objective.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
includes
|
Union[List[TObjective], TObjective]
|
Objective class or list of objective classes to be returned. Defaults to Objective. |
Objective
|
excludes
|
Union[List[TObjective], TObjective, None]
|
Objective class or list of specific objective classes to be excluded from the return. Defaults to None. |
None
|
exact
|
bool
|
Boolean to distinguish if only the exact classes listed in includes and no subclasses inherenting from this class shall be returned. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Outputs
|
List[AnyOutput]: List of output features fitting to the passed requirements. |
Source code in bofire/data_models/domain/features.py
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 |
|
get_keys_by_objective(includes=Objective, excludes=None, exact=False)
Get keys of output features filtered by the type of the attached objective.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
includes
|
Union[List[TObjective], TObjective]
|
Objective class or list of objective classes to be returned. Defaults to Objective. |
Objective
|
excludes
|
Union[List[TObjective], TObjective, None]
|
Objective class or list of specific objective classes to be excluded from the return. Defaults to None. |
None
|
exact
|
bool
|
Boolean to distinguish if only the exact classes listed in includes and no subclasses inherenting from this class shall be returned. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of output feature keys fitting to the passed requirements. |
Source code in bofire/data_models/domain/features.py
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 |
|
preprocess_experiments_all_valid_outputs(experiments, output_feature_keys=None)
Method to get a dataframe where non-valid entries of all output feature are removed
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe with experimental data |
required |
output_feature_keys
|
Optional[List]
|
List of output feature keys which should be considered for removal of invalid values. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Dataframe with all experiments where only valid entries of the selected features are included |
Source code in bofire/data_models/domain/features.py
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
|
preprocess_experiments_any_valid_output(experiments)
Method to get a dataframe where at least one output feature has a valid entry
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe with experimental data |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Dataframe with all experiments where at least one output feature has a valid entry |
Source code in bofire/data_models/domain/features.py
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
preprocess_experiments_one_valid_output(output_feature_key, experiments)
Method to get a dataframe where non-valid entries of the provided output feature are removed
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiments
|
DataFrame
|
Dataframe with experimental data |
required |
output_feature_key
|
str
|
The feature based on which non-valid entries rows are removed |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Dataframe with all experiments where only valid entries of the specific feature are included |
Source code in bofire/data_models/domain/features.py
971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 |
|