Steady state evolver
This file is part of the TPOT library.
The current version of TPOT was developed at Cedars-Sinai by: - Pedro Henrique Ribeiro (https://github.com/perib, https://www.linkedin.com/in/pedro-ribeiro/) - Anil Saini (anil.saini@cshs.org) - Jose Hernandez (jgh9094@gmail.com) - Jay Moran (jay.moran@cshs.org) - Nicholas Matsumoto (nicholas.matsumoto@cshs.org) - Hyunjun Choi (hyunjun.choi@cshs.org) - Miguel E. Hernandez (miguel.e.hernandez@cshs.org) - Jason Moore (moorejh28@gmail.com)
The original version of TPOT was primarily developed at the University of Pennsylvania by: - Randal S. Olson (rso@randalolson.com) - Weixuan Fu (weixuanf@upenn.edu) - Daniel Angell (dpa34@drexel.edu) - Jason Moore (moorejh28@gmail.com) - and many more generous open-source contributors
TPOT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
TPOT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with TPOT. If not, see http://www.gnu.org/licenses/.
SteadyStateEvolver
¶
Source code in tpot2/evolvers/steady_state_evolver.py
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 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 741 742 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 |
|
__init__(individual_generator, objective_functions, objective_function_weights, objective_names=None, objective_kwargs=None, bigger_is_better=True, initial_population_size=50, population_size=300, max_evaluated_individuals=None, early_stop=None, early_stop_mins=None, early_stop_tol=0.001, max_time_mins=float('inf'), max_eval_time_mins=10, n_jobs=1, memory_limit='4GB', client=None, crossover_probability=0.2, mutate_probability=0.7, mutate_then_crossover_probability=0.05, crossover_then_mutate_probability=0.05, n_parents=2, survival_selector=survival_select_NSGA2, parent_selector=tournament_selection_dominated, budget_range=None, budget_scaling=0.5, individuals_until_end_budget=1, stepwise_steps=5, verbose=0, periodic_checkpoint_folder=None, callback=None, rng=None)
¶
Whereas the base_evolver uses a generational approach, the steady state evolver continuously generates individuals as resources become available.
This evolver will simultaneously evaluated n_jobs individuals. As soon as one individual is evaluated, the current population is updated with survival_selector, a new individual is generated from parents selected with parent_selector, and the new individual is immediately submitted for evaluation. In contrast, the base_evolver batches evaluations in generations, and only updates the population and creates new individuals after all individuals in the current generation are evaluated.
In practice, this means that steady state evolver is more likely to use all cores at all times, allowing for flexibility is duration of evaluations and number of evaluations. However, it may also generate less diverse populations as a result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
individual_generator |
generator
|
Generator that yields new base individuals. Used to generate initial population. |
required |
objective_functions |
list of callables
|
list of functions that get applied to the individual and return a float or list of floats If an objective function returns multiple values, they are all concatenated in order with respect to objective_function_weights and early_stop_tol. |
required |
objective_function_weights |
list of floats
|
list of weights for each objective function. Sign flips whether bigger is better or not |
required |
objective_names |
list of strings
|
Names of the objectives. If None, objective0, objective1, etc. will be used |
None
|
objective_kwargs |
dict
|
Dictionary of keyword arguments to pass to the objective function |
None
|
bigger_is_better |
bool
|
If True, the objective function is maximized. If False, the objective function is minimized. Use negative weights to reverse the direction. |
True
|
initial_population_size |
int
|
Number of random individuals to generate in the initial population. These will all be randomly sampled, all other subsequent individuals will be generated from the population. |
50
|
population_size |
int
|
Note: This is different from the base_evolver. In steady_state_evolver, the population_size is the number of individuals to keep in the live population. This is the total number of best individuals (as determined by survival_selector) to keep in the population. New individuals are generated from this population size. In base evolver, this is also the number of individuals to generate in each generation, however, here, we generate individuals as resources become available so there is no concept of a generation. It is recommended to use a higher population_size to ensure diversity in the population. |
50
|
max_evaluated_individuals |
int
|
Maximum number of individuals to evaluate after which training is terminated. If None, will evaluate until time limit is reached. |
None
|
early_stop |
int
|
If the best individual has not improved in this many evaluations, stop training. Note: Also different from base_evolver. In base evolver, this is the number of generations without improvement. Here, it is the number of individuals evaluated without improvement. Naturally, a higher value is recommended. |
None
|
early_stop_mins |
int
|
If the best individual has not improved in this many minutes, stop training. early_stop_tol : float, list of floats, or None, default=0.001 -list of floats list of tolerances for each objective function. If the difference between the best score and the current score is less than the tolerance, the individual is considered to have converged If an index of the list is None, that item will not be used for early stopping -int If an int is given, it will be used as the tolerance for all objectives |
None
|
max_time_mins |
float
|
Maximum time to run the optimization. If none or inf, will run until the end of the generations. |
float("inf")
|
max_eval_time_mins |
float
|
Maximum time to evaluate a single individual. If none or inf, there will be no time limit per evaluation. |
10
|
n_jobs |
int
|
Number of processes to run in parallel. |
1
|
memory_limit |
str
|
Memory limit for each job. See Dask LocalCluster documentation for more information. |
None
|
client |
Client
|
A dask client to use for parallelization. If not None, this will override the n_jobs and memory_limit parameters. If None, will create a new client with num_workers=n_jobs and memory_limit=memory_limit. |
None
|
crossover_probability |
float
|
Probability of generating a new individual by crossover between two individuals. |
.2
|
mutate_probability |
float
|
Probability of generating a new individual by crossover between one individuals. |
.7
|
mutate_then_crossover_probability |
float
|
Probability of generating a new individual by mutating two individuals followed by crossover. |
.05
|
crossover_then_mutate_probability |
float
|
Probability of generating a new individual by crossover between two individuals followed by a mutation of the resulting individual. |
.05
|
n_parents |
int
|
Number of parents to use for crossover. Must be greater than 1. |
2
|
survival_selector |
function
|
Function to use to select individuals for survival. Must take a matrix of scores and return selected indexes. Used to selected population_size * survival_percentage individuals at the start of each generation to use for mutation and crossover. |
survival_select_NSGA2
|
parent_selector |
function
|
Function to use to select pairs parents for crossover and individuals for mutation. Must take a matrix of scores and return selected indexes. |
parent_select_NSGA2
|
budget_range |
list[start, end]
|
This parameter is used for the successive halving algorithm. A starting and ending budget to use for the budget scaling. The evolver will interpolate between these values over the generations_until_end_budget. Use is dependent on the objective functions. (In TPOTEstimator this corresponds to the percentage of the data to sample.) |
None
|
budget_scaling |
A scaling factor to use when determining how fast we move the budget from the start to end budget. |
0.5
|
|
evaluations_until_end_budget |
int
|
The number of evaluations to run before reaching the max budget. |
1
|
stepwise_steps |
int
|
The number of staircase steps to take when interpolating the budget. |
1
|
verbose |
int
|
How much information to print during the optimization process. Higher values include the information from lower values. 0. nothing 1. progress bar 2. evaluations progress bar 3. best individual 4. warnings
|
0
|
periodic_checkpoint_folder |
str
|
Folder to save the population to periodically. If None, no periodic saving will be done. If provided, training will resume from this checkpoint. |
None
|
callback |
CallBackInterface
|
Callback object. Not implemented |
None
|
rng |
(Generator, None)
|
An object for reproducability of experiments. This value will be passed to numpy.random.default_rng() to create an instnce of the genrator to pass to other classes
|
None
|
Attributes:
Name | Type | Description |
---|---|---|
population |
Population
|
The population of individuals. Use population.population to access the individuals in the current population. Use population.evaluated_individuals to access a data frame of all individuals that have been explored. |
Source code in tpot2/evolvers/steady_state_evolver.py
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 |
|
get_unevaluated_individuals(column_names, budget=None, individual_list=None)
¶
This function is used to get a list of individuals in the current population that have not been evaluated yet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column_names |
list of strings
|
Names of the columns to check for unevaluated individuals (generally objective functions). |
required |
budget |
float
|
Budget to use when checking for unevaluated individuals. If None, will not check the budget column. Finds individuals who have not been evaluated with the given budget on column names. |
None
|
individual_list |
list of individuals
|
List of individuals to check for unevaluated individuals. If None, will use the current population. |
None
|
Source code in tpot2/evolvers/steady_state_evolver.py
optimize()
¶
Creates an initial population and runs the evolutionary algorithm for the given number of generations. If generations is None, will use self.generations.
Source code in tpot2/evolvers/steady_state_evolver.py
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 |
|
ind_crossover(ind1, ind2, rng)
¶
Calls the ind1.crossover(ind2, rng=rng)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ind1 |
BaseIndividual
|
|
required |
ind2 |
BaseIndividual
|
|
required |
rng |
int or Generator
|
A numpy random generator to use for reproducibility |
required |
Source code in tpot2/evolvers/steady_state_evolver.py
ind_mutate(ind, rng)
¶
Calls the ind.mutate method on the individual
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ind |
BaseIndividual
|
The individual to mutate |
required |
rng |
int or Generator
|
A numpy random generator to use for reproducibility |
required |