Initialization#
Random expression generation.
grow()andfull()– the two tree-creation methods of Koza (1992): full trees have every leaf at the maximum depth, grow trees may stop earlier;ramped_half_and_half()– half grow, half full, over a range of depths, the standard initialization of genetic programming;ptc2()– the probabilistic tree creation algorithm PTC2 of Luke (2000), which controls the size of the trees instead of their depth.
Examples#
>>> import numpy as np
>>> from eqdisco.expr import PrimitiveSet
>>> from eqdisco.generate import full, ramped_half_and_half
>>> pset = PrimitiveSet(n_features=2, functions=("add", "mul"))
>>> rng = np.random.default_rng(0)
>>> full(pset, 2, rng).depth
2
>>> len(ramped_half_and_half(pset, 10, rng, 1, 3))
10
Grow, full, ramped half-and-half and PTC2 tree generation.
Functions#
|
Grow method: functions and terminals mixed until |
|
Full method: every leaf at depth |
|
|
|
PTC2: a random tree with about |
|
Convenience wrapper: |