Basic usageΒΆ
Follow these steps to solve a basic regression problem:
Define an objective function. The objective function takes an individual as an argument and updates the fitness of the individual.
def objective(individual): individual.fitness = ... return individual
Define a callback function to record information about the progress of the evolution:
history = {} history["fitness_parents"] = [] def recording_callback(pop): history["fitness_parents"].append(pop.fitness_parents())
Use the evolve function that uses default hyperparameters and starts the evolution:
cgp.evolve(obj, print_progress=True, callback=recording_callback)