-
Notifications
You must be signed in to change notification settings - Fork 314
Description
gplearn already has a protected division: np.where(np.abs(x2) > 0.001, np.divide(x1, x2), 1.) and protected log: np.where(np.abs(x1) > 0.001, np.log(np.abs(x1)), 0.).
Both of these are common but both introduce discontinuities which can be undesirable (see eg Keijzer; Ni, Drieberg and Rockett; Nicolau and Agapitos). Alternatives include:
-
The analytic quotient (Ni, J., Drieberg, R.H., Rockett, P.I.: The use of an analytic quotient operator in
genetic programming. Transactions On Evolutionary Computation 17(1) (2013)) is defined as:$AQ(a, b) = \frac{a}{\sqrt{1 + b^2}}$ . -
Another protected log
np.log(1 + np.abs(x1)).
Of course these would be of interest as alternatives, not replacements. If this addition would be useful I can generate a PR. Would these names be suitable:
aq=def _analytic_quotient(x1, x2)cpl=def _continuous_protected_log(x1)