Appendix B
From the GP-OLS MATLAB toolbox
The GP-OLS MATLAB toolbox accompanied the paper of Madár, Abonyi and Szeifert [1] and is distributed on the web site of the author’s research group (https://www.abonyilab.com/gp_index). Its documentation describes a population structure that holds the chromosomes, the trees of the individuals, and the symbols, the operators and variables of the equations, and four functions that a program calls in turn: gpols_init(popusize, maxtreedepth, symbols) creates the population variable and random initial trees; gpols_evaluate(popu, ixv, X, Y, Q, opte) determines the linear parameters, applies orthogonal least squares to eliminate subtrees and computes the fitness of the individuals with indices ixv; gpols_mainloop executes one evolutionary loop and steps to the next generation; and the script gpols_result writes the current solution and the final result. The vector opte holds the two parameters of the tree-size penalty, the OLS threshold (a fraction between 0 and 1, or an integer number of terms) and a flag of polynomial evaluation; the optional vector Q turns least squares into weighted least squares.
In eqdisco the whole program is one estimator:
import eqdisco as eq model = eq.GPOLSRegressor( population_size=50, # popusize of gpols_init max_depth=5, # maxtreedepth of gpols_init functions=("add", "mul"), # the operator symbols; terminals are the columns of X err_threshold=0.02, # opte(3), the OLS threshold generations=30, # the number of gpols_mainloop calls random_state=0, ).fit(X, y) print(model.equation_) # gpols_result: the best equation print(model.gene_table()) # terms, weights and error reduction ratios
Table B.1 maps the elements of the toolbox to eqdisco.
GP-OLS MATLAB toolbox | eqdisco |
gpols_init(popusize, maxtreedepth, symbols) | GPOLSRegressor(population_size, max_depth, functions) |
symbols (operators and terminals) | functions; terminals are the columns of X, named by feature_names |
gpols_evaluate(popu, ixv, X, Y, Q, opte) | fit(X, y); every new individual is evaluated internally |
opte(1:2), tree-size penalty | parsimony, max_genes, max_depth, model_selection |
opte(3), OLS threshold | err_threshold (a fraction of the explained variance) |
opte(4), polynomial evaluation | functions=("add", "mul"), the default |
Q, weighted least squares | not provided in version 1.0 |
gpols_mainloop | generations, patience, time_limit |
gpols_result | equation_, gene_table(), history_, pareto_front_ |
lagged regressors built by hand | NARXRegressor(GPOLSRegressor(...), na, nb, nk) |
– | backward_check=True: removal of collinear terms |
– | err_guided: ERR-guided variation (experimental) |
– | CooperativeOLSRegressor: a shared library of terms |
Differences in behavior. Five differences should be known when results of the two implementations are compared.
- eqdisco estimates the weights of the terms with an intercept and a tiny ridge penalty (ridge=1e-8), so that duplicated or constant terms do not make the least-squares problem singular.
- The error reduction ratios are computed on centered data, so that they sum to the coefficient of determination of the model (section 4.2.1).
- After the forward pruning, the backward check removes terms whose unique contribution is below the threshold (section 4.2.3); backward_check=False reproduces the original pruning.
- The final model is selected from the archive of non-dominated individuals by the Bayesian information criterion (model_selection="bic"); model_selection="best" returns the most accurate individual, as the toolbox does.
- For dynamic models the identification is followed by free-run simulation (NARXRegressor.simulate), the validation recommended in the paper.