eqdisco.models.GPOLSRegressor#

class eqdisco.models.GPOLSRegressor(population_size=300, generations=50, max_genes=6, functions=('add', 'mul'), init_depth=(1, 3), max_depth=4, err_threshold=0.01, backward_check=True, selection='tournament', tournament_size=5, p_crossover=0.8, p_high_level=0.3, p_add_gene=0.2, p_delete_gene=0.05, p_constant=0.0, const_range=(-5.0, 5.0), ridge=1e-08, parsimony=0.0, loss='mse', err_guided=False, elitism=1, n_islands=1, migration_interval=10, migration_size=2, seed_equations=None, model_selection='bic', selection_tolerance=0.01, refit=False, patience=None, time_limit=None, max_evaluations=None, feature_names=None, random_state=None, verbose=0)[source]#

Bases: MultiGeneRegressor

GP-OLS: genetic programming with orthogonal-least-squares pruning (Madár et al., 2005).

Every individual is a sum of terms (genes); orthogonal least squares estimates the weights and the error reduction ratio of every term, and terms whose ERR is below err_threshold are removed from the individual (Lamarckian pruning). The method was proposed for the structure identification of linear-in-parameters models such as NAARX and polynomial ARMA models; with eqdisco.dynamics.NARXRegressor it identifies the order and the structure of nonlinear input–output models.

Parameters:
err_thresholdfloat, default=0.01

Terms with an ERR below this value are pruned.

backward_checkbool, default=True

After the ERR pruning in forward order, remove one by one the terms whose unique contribution (the share of output variance lost when the term alone is removed) is below err_threshold. This guards against collinear terms that receive a large ERR only because of their position in the order (an addition of eqdisco to the original method).

err_guided{False, True, “replace”}, default=False

ERR-guided variation (new in eqdisco, experimental; see MultiGeneRegressor).

functionsdefault (“add”, “mul”)

The function set of the linear-in-parameters models of the original paper; any primitives can be used.

The other parameters are those of :class:`MultiGeneRegressor`.

Examples

>>> import numpy as np
>>> from eqdisco import GPOLSRegressor
>>> rng = np.random.default_rng(0)
>>> X = rng.normal(size=(300, 3))
>>> y = 1.5 * X[:, 0] * X[:, 1] - 0.8 * X[:, 2] ** 2 + 0.01 * rng.normal(size=300)
>>> m = GPOLSRegressor(generations=20, random_state=0).fit(X, y)
>>> m.score(X, y) > 0.99
True