Estimator
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/.
TPOTEstimator
¶
Bases: BaseEstimator
Source code in tpot2/tpot_estimator/estimator.py
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 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 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 |
|
classes_
property
¶
The classes labels. Only exist if the last step is a classifier.
__init__(search_space, scorers, scorers_weights, classification, cv=10, other_objective_functions=[], other_objective_functions_weights=[], objective_function_names=None, bigger_is_better=True, export_graphpipeline=False, memory=None, categorical_features=None, preprocessing=False, population_size=50, initial_population_size=None, population_scaling=0.5, generations_until_end_population=1, generations=None, max_time_mins=60, max_eval_time_mins=10, validation_strategy='none', validation_fraction=0.2, disable_label_encoder=False, early_stop=None, scorers_early_stop_tol=0.001, other_objectives_early_stop_tol=None, threshold_evaluation_pruning=None, threshold_evaluation_scaling=0.5, selection_evaluation_pruning=None, selection_evaluation_scaling=0.5, min_history_threshold=20, survival_percentage=1, crossover_probability=0.2, mutate_probability=0.7, mutate_then_crossover_probability=0.05, crossover_then_mutate_probability=0.05, survival_selector=survival_select_NSGA2, parent_selector=tournament_selection_dominated, budget_range=None, budget_scaling=0.5, generations_until_end_budget=1, stepwise_steps=5, n_jobs=1, memory_limit=None, client=None, processes=True, warm_start=False, periodic_checkpoint_folder=None, callback=None, verbose=0, scatter=True, random_state=None)
¶
An sklearn baseestimator that uses genetic programming to optimize a pipeline.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
search_space |
(String, SearchSpace)
|
Note that TPOT MDR may be slow to run because the feature selection routines are computationally expensive, especially on large datasets. |
|
required |
scorers |
(list, scorer)
|
A scorer or list of scorers to be used in the cross-validation process. see https://scikit-learn.org/stable/modules/model_evaluation.html |
required |
scorers_weights |
list
|
A list of weights to be applied to the scorers during the optimization process. |
required |
classification |
bool
|
If True, the problem is treated as a classification problem. If False, the problem is treated as a regression problem. Used to determine the CV strategy. |
required |
cv |
(int, cross - validator)
|
|
10
|
other_objective_functions |
list
|
A list of other objective functions to apply to the pipeline. The function takes a single parameter for the graphpipeline estimator and returns either a single score or a list of scores. |
[]
|
other_objective_functions_weights |
list
|
A list of weights to be applied to the other objective functions. |
[]
|
objective_function_names |
list
|
A list of names to be applied to the objective functions. If None, will use the names of the objective functions. |
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
|
memory |
If supplied, pipeline will cache each transformer after calling fit with joblib.Memory. This feature is used to avoid computing the fit transformers within a pipeline if the parameters and input data are identical with another fitted pipeline during optimization process. - String 'auto': TPOT uses memory caching with a temporary directory and cleans it up upon shutdown. - String path of a caching directory TPOT uses memory caching with the provided directory and TPOT does NOT clean the caching directory up upon shutdown. If the directory does not exist, TPOT will create it. - Memory object: TPOT uses the instance of joblib.Memory for memory caching, and TPOT does NOT clean the caching directory up upon shutdown. - None: TPOT does not use memory caching. |
None
|
|
categorical_features |
Categorical columns to inpute and/or one hot encode during the preprocessing step. Used only if preprocessing is not False. - None : If None, TPOT2 will automatically use object columns in pandas dataframes as objects for one hot encoding in preprocessing. - List of categorical features. If X is a dataframe, this should be a list of column names. If X is a numpy array, this should be a list of column indices |
None
|
|
preprocessing |
(bool or BaseEstimator / Pipeline)
|
EXPERIMENTAL - will be changed in future versions A pipeline that will be used to preprocess the data before CV. Note that the parameters for these steps are not optimized. Add them to the search space to be optimized. - bool : If True, will use a default preprocessing pipeline which includes imputation followed by one hot encoding. - Pipeline : If an instance of a pipeline is given, will use that pipeline as the preprocessing pipeline. |
False
|
population_size |
int
|
Size of the population |
50
|
initial_population_size |
int
|
Size of the initial population. If None, population_size will be used. |
None
|
population_scaling |
int
|
Scaling factor to use when determining how fast we move the threshold moves from the start to end percentile. |
0.5
|
generations_until_end_population |
int
|
Number of generations until the population size reaches population_size |
1
|
generations |
int
|
Number of generations to run |
50
|
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. |
5
|
validation_strategy |
str
|
EXPERIMENTAL The validation strategy to use for selecting the final pipeline from the population. TPOT2 may overfit the cross validation score. A second validation set can be used to select the final pipeline. - 'auto' : Automatically determine the validation strategy based on the dataset shape. - 'reshuffled' : Use the same data for cross validation and final validation, but with different splits for the folds. This is the default for small datasets. - 'split' : Use a separate validation set for final validation. Data will be split according to validation_fraction. This is the default for medium datasets. - 'none' : Do not use a separate validation set for final validation. Select based on the original cross-validation score. This is the default for large datasets. |
'none'
|
validation_fraction |
float
|
EXPERIMENTAL The fraction of the dataset to use for the validation set when validation_strategy is 'split'. Must be between 0 and 1. |
0.2
|
disable_label_encoder |
bool
|
If True, TPOT will check if the target needs to be relabeled to be sequential ints from 0 to N. This is necessary for XGBoost compatibility. If the labels need to be encoded, TPOT2 will use sklearn.preprocessing.LabelEncoder to encode the labels. The encoder can be accessed via the self.label_encoder_ attribute. If False, no additional label encoders will be used. |
False
|
early_stop |
int
|
Number of generations without improvement before early stopping. All objectives must have converged within the tolerance for this to be triggered. In general a value of around 5-20 is good. |
None
|
scorers_early_stop_tol |
-list of floats list of tolerances for each scorer. 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 |
0.001
|
|
other_objectives_early_stop_tol |
-list of floats list of tolerances for each of the other 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
|
|
threshold_evaluation_pruning |
list[start, end]
|
starting and ending percentile to use as a threshold for the evaluation early stopping. Values between 0 and 100. |
None
|
threshold_evaluation_scaling |
float [0,inf)
|
A scaling factor to use when determining how fast we move the threshold moves from the start to end percentile. Must be greater than zero. Higher numbers will move the threshold to the end faster. |
0.5
|
selection_evaluation_pruning |
list
|
A lower and upper percent of the population size to select each round of CV. Values between 0 and 1. |
None
|
selection_evaluation_scaling |
float
|
A scaling factor to use when determining how fast we move the threshold moves from the start to end percentile. Must be greater than zero. Higher numbers will move the threshold to the end faster. |
0.5
|
min_history_threshold |
int
|
The minimum number of previous scores needed before using threshold early stopping. |
0
|
survival_percentage |
float
|
Percentage of the population size to utilize for mutation and crossover at the beginning of the generation. The rest are discarded. Individuals are selected with the selector passed into survival_selector. The value of this parameter must be between 0 and 1, inclusive. For example, if the population size is 100 and the survival percentage is .5, 50 individuals will be selected with NSGA2 from the existing population. These will be used for mutation and crossover to generate the next 100 individuals for the next generation. The remainder are discarded from the live population. In the next generation, there will now be the 50 parents + the 100 individuals for a total of 150. Surivival percentage is based of the population size parameter and not the existing population size (current population size when using successive halving). Therefore, in the next generation we will still select 50 individuals from the currently existing 150. |
1
|
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
|
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]
|
A starting and ending budget to use for the budget scaling. |
None
|
budget_scaling |
A scaling factor to use when determining how fast we move the budget from the start to end budget. |
0.5
|
|
generations_until_end_budget |
int
|
The number of generations to run before reaching the max budget. |
1
|
stepwise_steps |
int
|
The number of staircase steps to take when scaling the budget and population size. |
1
|
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
|
processes |
bool
|
If True, will use multiprocessing to parallelize the optimization process. If False, will use threading. True seems to perform better. However, False is required for interactive debugging. |
True
|
warm_start |
bool
|
If True, will use the continue the evolutionary algorithm from the last generation of the previous run. |
False
|
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
|
verbose |
int
|
How much information to print during the optimization process. Higher values include the information from lower values. 0. nothing 1. progress bar
|
1
|
scatter |
bool
|
If True, will scatter the data to the dask workers. If False, will not scatter the data. This can be useful for debugging. |
True
|
random_state |
(int, None)
|
A seed 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 |
---|---|---|
fitted_pipeline_ |
GraphPipeline
|
A fitted instance of the GraphPipeline that inherits from sklearn BaseEstimator. This is fitted on the full X, y passed to fit. |
evaluated_individuals |
A pandas data frame containing data for all evaluated individuals in the run.
|
Columns: - objective functions : The first few columns correspond to the passed in scorers and objective functions - Parents : A tuple containing the indexes of the pipelines used to generate the pipeline of that row. If NaN, this pipeline was generated randomly in the initial population. - Variation_Function : Which variation function was used to mutate or crossover the parents. If NaN, this pipeline was generated randomly in the initial population. - Individual : The internal representation of the individual that is used during the evolutionary algorithm. This is not an sklearn BaseEstimator. - Generation : The generation the pipeline first appeared. - Pareto_Front : The nondominated front that this pipeline belongs to. 0 means that its scores is not strictly dominated by any other individual. To save on computational time, the best frontier is updated iteratively each generation. The pipelines with the 0th pareto front do represent the exact best frontier. However, the pipelines with pareto front >= 1 are only in reference to the other pipelines in the final population. All other pipelines are set to NaN. - Instance : The unfitted GraphPipeline BaseEstimator. - validation objective functions : Objective function scores evaluated on the validation set. - Validation_Pareto_Front : The full pareto front calculated on the validation set. This is calculated for all pipelines with Pareto_Front equal to 0. Unlike the Pareto_Front which only calculates the frontier and the final population, the Validation Pareto Front is calculated for all pipelines tested on the validation set. |
pareto_front |
The same pandas dataframe as evaluated individuals, but containing only the frontier pareto front pipelines.
|
|
Source code in tpot2/tpot_estimator/estimator.py
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 |
|
apply_make_pipeline(ind, preprocessing_pipeline=None, export_graphpipeline=False, **pipeline_kwargs)
¶
Helper function to create a column of sklearn pipelines from the tpot2 individual class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ind |
The individual to convert to a pipeline. |
required | |
preprocessing_pipeline |
The preprocessing pipeline to include before the individual's pipeline. |
None
|
|
export_graphpipeline |
Force the pipeline to be exported as a graph pipeline. Flattens all nested pipelines, FeatureUnions, and GraphPipelines into a single GraphPipeline. |
False
|
|
pipeline_kwargs |
Keyword arguments to pass to the export_pipeline or export_flattened_graphpipeline method. |
{}
|
Returns:
Type | Description |
---|---|
sklearn estimator
|
|
Source code in tpot2/tpot_estimator/estimator_utils.py
check_empty_values(data)
¶
Checks for empty values in a dataset.
Args: data (numpy.ndarray or pandas.DataFrame): The dataset to check.
Returns: bool: True if the dataset contains empty values, False otherwise.
Source code in tpot2/tpot_estimator/estimator.py
check_if_y_is_encoded(y)
¶
Checks if the target y is composed of sequential ints from 0 to N. XGBoost requires the target to be encoded in this way.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y |
The target vector. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the target is encoded as sequential ints from 0 to N, False otherwise |
Source code in tpot2/tpot_estimator/estimator_utils.py
convert_parents_tuples_to_integers(row, object_to_int)
¶
Helper function to convert the parent rows into integers representing the index of the parent in the population.
Original pandas dataframe using a custom index for the parents. This function converts the custom index to an integer index for easier manipulation by end users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row |
The row to convert. |
required | |
object_to_int |
A dictionary mapping the object to an integer index. |
required |
Returns
tuple The row with the custom index converted to an integer index.
Source code in tpot2/tpot_estimator/estimator_utils.py
cross_val_score_objective(estimator, X, y, scorers, cv, fold=None)
¶
Compute the cross validated scores for a estimator. Only fits the estimator once per fold, and loops over the scorers to evaluate the estimator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
estimator |
The estimator to fit and score. |
required | |
X |
The feature matrix. |
required | |
y |
The target vector. |
required | |
scorers |
The scorers to use. If a list, will loop over the scorers and return a list of scorers. If a single scorer, will return a single score. |
required | |
cv |
The cross-validator to use. For example, sklearn.model_selection.KFold or sklearn.model_selection.StratifiedKFold. |
required | |
fold |
The fold to return the scores for. If None, will return the mean of all the scores (per scorer). Default is None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
scores |
ndarray or float
|
The scores for the estimator per scorer. If fold is None, will return the mean of all the scores (per scorer). Returns a list if multiple scorers are used, otherwise returns a float for the single scorer. |
Source code in tpot2/tpot_estimator/cross_val_utils.py
objective_function_generator(pipeline, x, y, scorers, cv, other_objective_functions, step=None, budget=None, is_classification=True, export_graphpipeline=False, **pipeline_kwargs)
¶
Uses cross validation to evaluate the pipeline using the scorers, and concatenates results with scores from standalone other objective functions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline |
The individual to evaluate. |
required | |
x |
The feature matrix. |
required | |
y |
The target vector. |
required | |
scorers |
The scorers to use for cross validation. |
required | |
cv |
The cross-validator to use. For example, sklearn.model_selection.KFold or sklearn.model_selection.StratifiedKFold. If an int, will use sklearn.model_selection.KFold with n_splits=cv. |
required | |
other_objective_functions |
A list of standalone objective functions to evaluate the pipeline. With signature obj(pipeline) -> float. or obj(pipeline) -> np.ndarray These functions take in the unfitted estimator. |
required | |
step |
The fold to return the scores for. If None, will return the mean of all the scores (per scorer). Default is None. |
None
|
|
budget |
The budget to subsample the data. If None, will use the full dataset. Default is None. Will subsample budget*len(x) samples. |
None
|
|
is_classification |
If True, will stratify the subsampling. Default is True. |
True
|
|
export_graphpipeline |
Force the pipeline to be exported as a graph pipeline. Flattens all nested sklearn pipelines, FeatureUnions, and GraphPipelines into a single GraphPipeline. |
False
|
|
pipeline_kwargs |
Keyword arguments to pass to the export_pipeline or export_flattened_graphpipeline method. |
{}
|
Returns:
Type | Description |
---|---|
ndarray
|
The concatenated scores for the pipeline. The first len(scorers) elements are the cross validation scores, and the remaining elements are the standalone objective functions. |
Source code in tpot2/tpot_estimator/estimator_utils.py
remove_underrepresented_classes(x, y, min_count)
¶
Helper function to remove classes with less than min_count samples from the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
The feature matrix. |
required | |
y |
The target vector. |
required | |
min_count |
The minimum number of samples to keep a class. |
required |
Returns:
Type | Description |
---|---|
(ndarray, ndarray)
|
The feature matrix and target vector with rows from classes with less than min_count samples removed. |
Source code in tpot2/tpot_estimator/estimator_utils.py
val_objective_function_generator(pipeline, X_train, y_train, X_test, y_test, scorers, other_objective_functions, export_graphpipeline=False, **pipeline_kwargs)
¶
Trains a pipeline on a training set and evaluates it on a test set using the scorers and other objective functions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline |
The individual to evaluate. |
required | |
X_train |
The feature matrix of the training set. |
required | |
y_train |
The target vector of the training set. |
required | |
X_test |
The feature matrix of the test set. |
required | |
y_test |
The target vector of the test set. |
required | |
scorers |
The scorers to use for cross validation. |
required | |
other_objective_functions |
A list of standalone objective functions to evaluate the pipeline. With signature obj(pipeline) -> float. or obj(pipeline) -> np.ndarray These functions take in the unfitted estimator. |
required | |
export_graphpipeline |
Force the pipeline to be exported as a graph pipeline. Flattens all nested sklearn pipelines, FeatureUnions, and GraphPipelines into a single GraphPipeline. |
False
|
|
pipeline_kwargs |
Keyword arguments to pass to the export_pipeline or export_flattened_graphpipeline method. |
{}
|
Returns:
Type | Description |
---|---|
ndarray
|
The concatenated scores for the pipeline. The first len(scorers) elements are the cross validation scores, and the remaining elements are the standalone objective functions. |