'Set up the genetic programming algorithm for pipeline optimization.
Parameters
generations: int, optional (default: 100)
Number of iterations to the run pipeline optimization process.
Generally, TPOT will work better when you give it more generations (and
therefore time) to optimize the pipeline. TPOT will evaluate
POPULATION_SIZE + GENERATIONS x OFFSPRING_SIZE pipelines in total.
population_size: int, optional (default: 100)
Number of individuals to retain in the GP population every generation.
Generally, TPOT will work better when you give it more individuals
(and therefore time) to optimize the pipeline. TPOT will evaluate
POPULATION_SIZE + GENERATIONS x OFFSPRING_SIZE pipelines in total.
offspring_size: int, optional (default: None)
Number of offspring to produce in each GP generation.
By default, offspring_size = population_size.
mutation_rate: float, optional (default: 0.9)
Mutation rate for the genetic programming algorithm in the range [0.0, 1.0].
This parameter tells the GP algorithm how many pipelines to apply random
changes to every generation. We recommend using the default parameter unless
you understand how the mutation rate affects GP algorithms.
crossover_rate: float, optional (default: 0.1)
Crossover rate for the genetic programming algorithm in the range [0.0, 1.0].
This parameter tells the genetic programming algorithm how many pipelines to
"breed" every generation. We recommend using the default parameter unless you
understand how the mutation rate affects GP algorithms.
scoring: string or callable, optional
Function used to evaluate the quality of a given pipeline for the
problem. By default, accuracy is used for classification problems and
mean squared error (MSE) for regression problems.
Offers the same options as sklearn.model_selection.cross_val_score as well as
a built-in score \'balanced_accuracy\'. Classification metrics:
[\'accuracy\', \'adjusted_rand_score\', \'average_precision\', \'balanced_accuracy\',
\'f1\', \'f1_macro\', \'f1_micro\', \'f1_samples\', \'f1_weighted\',
\'precision\', \'precision_macro\', \'precision_micro\', \'precision_samples\',
\'precision_weighted\', \'recall\', \'recall_macro\', \'recall_micro\',
\'recall_samples\', \'recall_weighted\', \'roc_auc\']
Regression metrics:
[\'neg_median_absolute_error\', \'neg_mean_absolute_error\',
\'neg_mean_squared_error\', \'r2\']
If you would like to use a custom scoring function, you can pass a callable
function to this parameter with the signature scorer(y_true, y_pred).
See the section on scoring functions in the documentation for more details.
TPOT assumes that any custom scoring function with "error" or "loss" in the
name is meant to be minimized, whereas any other functions will be maximized.
cv: int or cross-validation generator, optional (default: 5)
If CV is a number, then it is the number of folds to evaluate each
pipeline over in k-fold cross-validation during the TPOT optimization
process. If it is an object then it is an object to be used as a
cross-validation generator.
subsample: float, optional (default: 1.0)
Subsample ratio of the training instance. Setting it to 0.5 means that TPOT
randomly collects half of training samples for pipeline optimization process.
n_jobs: int, optional (default: 1)
Number of CPUs for evaluating pipelines in parallel during the TPOT
optimization process. Assigning this to -1 will use as many cores as available
on the computer.
max_time_mins: int, optional (default: None)
How many minutes TPOT has to optimize the pipeline.
If provided, this setting will override the "generations" parameter and allow
TPOT to run until it runs out of time.
max_eval_time_mins: int, optional (default: 5)
How many minutes TPOT has to optimize a single pipeline.
Setting this parameter to higher values will allow TPOT to explore more
complex pipelines, but will also allow TPOT to run longer.
random_state: int, optional (default: None)
Random number generator seed for TPOT. Use this parameter to make sure
that TPOT will give you the same results each time you run it against the
same data set with that seed.
config_dict: a Python dictionary or string, optional (default: None)
Python dictionary:
A dictionary customizing the operators and parameters that
TPOT uses in the optimization process.
For examples, see config_regressor.py and config_classifier.py
Path for configuration file:
A path to a configuration file for customizing the operators and parameters that
TPOT uses in the optimization process.
For examples, see config_regressor.py and config_classifier.py
String \'TPOT light\':
TPOT uses a light version of operator configuration dictionary instead of
the default one.
String \'TPOT MDR\':
TPOT uses a list of TPOT-MDR operator configuration dictionary instead of
the default one.
warm_start: bool, optional (default: False)
Flag indicating whether the TPOT instance will reuse the population from
previous calls to fit().
verbosity: int, optional (default: 0)
How much information TPOT communicates while it\'s running.
0 = none, 1 = minimal, 2 = high, 3 = all.
A setting of 2 or higher will add a progress bar during the optimization procedure.
disable_update_check: bool, optional (default: False)
Flag indicating whether the TPOT version checker should be disabled.
Returns
None'

def __init__(self, generations=100, population_size=100, offspring_size=None, mutation_rate=0.9, crossover_rate=0.1, scoring=None, cv=5, subsample=1.0, n_jobs=1, max_time_mins=None, max_eval_time_mins=5, random_state=None, config_dict=None, warm_start=False, verbosity=0, disable_update_check=False):

    if (self.__class__.__name__ == 'TPOTBase'):
        raise RuntimeError('Do    not    instantiate    the    TPOTBase    class    directly;    use    TPOTRegressor    or    TPOTClassifier    instead.')
    self.disable_update_check = disable_update_check
    if (not self.disable_update_check):
        update_check('tpot', __version__)
    self._pareto_front = None
    self._optimized_pipeline = None
    self.fitted_pipeline_ = None
    self._fitted_imputer = None
    self._pop = None
    self.warm_start = warm_start
    self.population_size = population_size
    self.generations = generations
    self.max_time_mins = max_time_mins
    self.max_eval_time_mins = max_eval_time_mins
    if offspring_size:
        self.offspring_size = offspring_size
    else:
        self.offspring_size = population_size
    self._setup_config(config_dict)
    self.operators = []
    self.arguments = []
    for key in sorted(self.config_dict.keys()):
        (op_class, arg_types) = TPOTOperatorClassFactory(key, self.config_dict[key], BaseClass=Operator, ArgBaseClass=ARGType)
        if op_class:
            self.operators.append(op_class)
            self.arguments += arg_types
    if (max_time_mins is not None):
        self.generations = 1000000
    self.mutation_rate = mutation_rate
    self.crossover_rate = crossover_rate
    if ((self.mutation_rate + self.crossover_rate) > 1):
        raise ValueError('The    sum    of    the    crossover    and    mutation    probabilities    must    be    <=    1.0.')
    self.verbosity = verbosity
    self.operators_context = {'make_pipeline': make_pipeline, 'make_union': make_union, 'StackingEstimator': StackingEstimator, 'FunctionTransformer': FunctionTransformer, 'copy': copy}
    self._pbar = None
    self.evaluated_individuals_ = {}
    self.random_state = random_state
    if scoring:
        if hasattr(scoring, '__call__'):
            scoring_name = scoring.__name__
            greater_is_better = (('loss' not in scoring_name) and ('error' not in scoring_name))
            SCORERS[scoring_name] = make_scorer(scoring, greater_is_better=greater_is_better)
            self.scoring_function = scoring_name
        else:
            if (scoring not in SCORERS):
                raise ValueError('The    scoring    function    {}    is    not    available.    Please    choose    a    valid    scoring    function    from    the    TPOT    documentation.'.format(scoring))
            self.scoring_function = scoring
    self.cv = cv
    self.subsample = subsample
    if ((self.subsample <= 0.0) or (self.subsample > 1.0)):
        raise ValueError('The    subsample    ratio    of    the    training    instance    must    be    in    the    range    (0.0,    1.0].')
    if (sys.platform.startswith('win') and (n_jobs != 1)):
        print('Warning:    Although    parallelization    is    currently    supported    in    TPOT    for    Windows,    pressing    Ctrl+C    will    freeze    the    optimization    process    without    saving    the    best    pipeline!    Thus,    Please    DO    NOT    press    Ctrl+C    during    the    optimization    procss    if    n_jobs    is    not    equal    to    1.    For    quick    test    in    Windows,    please    set    n_jobs    to    1    for    saving    the    best    pipeline    in    the    middle    of    the    optimization    process    via    Ctrl+C.')
    if (n_jobs == (-1)):
        self.n_jobs = cpu_count()
    else:
        self.n_jobs = n_jobs
    self._setup_pset()
    self._setup_toolbox()
