QDpy
Loading...
Searching...
No Matches
_search.py File Reference

Compare MAP-Elites with aggregate and case-wise genetic programming. More...

Go to the source code of this file.

Classes

class  qdpy.symbolic._search.SymbolicRegressionStats
 Applied search budget and numerical evaluation counts. More...
class  qdpy.symbolic._search.LinkedSymbolicRegressionStats
 Count attempted and accepted linked changes in symbolic regression. More...
class  qdpy.symbolic._search.SymbolicRegressionResult
 Retained regression models and the native QD archive, if used. More...
class  qdpy.symbolic._search._Grammar
class  qdpy.symbolic._search._TreeMixer
class  qdpy.symbolic._search._ModelPool
class  qdpy.symbolic._search._CasePool

Namespaces

namespace  qdpy

Functions

SymbolicRegressionResult qdpy.symbolic._search.symbolic_regression (X, y, *, str mode="structural", probes=None, int budget=512, int max_depth=4, int max_nodes=13, int max_parameters=4, operators=_DEFAULT_OPERATORS, literals=(1., 2.), int cells=24, int population_size=24, bool passive_archive=False, nonlinear_bounds=(-20., 20.), int fit_evaluations=48, int fit_restarts=4, int|None seed=None, novelty_binner=None, int novelty_history=256, variation="subtree", max_fit_evaluations=None)
 Search for equations using MAP-Elites or genetic programming.

Detailed Description

Compare MAP-Elites with aggregate and case-wise genetic programming.

Definition in file _search.py.

Function Documentation

◆ symbolic_regression()

SymbolicRegressionResult qdpy.symbolic._search.symbolic_regression ( X,
y,
* ,
str mode = "structural",
probes = None,
int budget = 512,
int max_depth = 4,
int max_nodes = 13,
int max_parameters = 4,
operators = _DEFAULT_OPERATORS,
literals = (1., 2.),
int cells = 24,
int population_size = 24,
bool passive_archive = False,
nonlinear_bounds = (-20., 20.),
int fit_evaluations = 48,
int fit_restarts = 4,
int | None seed = None,
novelty_binner = None,
int novelty_history = 256,
variation = "subtree",
max_fit_evaluations = None )

Search for equations using MAP-Elites or genetic programming.

Parameters
XFinite training sample matrix.
yOne finite training target per row.
modeStructural, semantic, gp, lexicase, epsilon-lexicase, or novelty-lexicase.
probesFixed unlabeled sample rows for feasibility and semantic descriptors.
budgetNumber of proposed trees, including duplicates.
max_depthMaximum number of edges from root to leaf.
max_nodesMaximum number of operator and leaf occurrences in a tree.
max_parametersMaximum number of coefficient leaves.
operatorsAllowed Expression operations.
literalsFixed numeric terminals in the grammar.
cellsNumber of semantic archive centroids.
novelty_binnerOptional callable returning hashable groups for training predictions.
novelty_historyMaximum number of historical output rows used for novelty counts.
population_sizeMaximum GP population size.
passive_archiveCollect a structural grid while GP selects by aggregate error.
nonlinear_boundsCoefficient bounds for the nonlinear optimizer.
fit_evaluationsTraining evaluation cap per unique structure.
fit_restartsNumber of nonlinear restarts per fit.
variationSubtree, template-linkage, or learned-linkage variation.
max_fit_evaluationsOptional total budget for training-expression evaluations.
seedSeed for variation, coefficient fitting, and archive geometry.
Returns
The retained models, native archive if present, and evaluation counts.
Fit equations to one labeled training dataset.

X has shape (samples, variables) and y has shape (samples,). Each
proposal spends one unit of budget, including repeats. Search starts
with the variable, literal, and free parameter terminals. Genetic
variation uses the supplied operator names, at most max_depth edges,
max_nodes nodes, and max_parameters free scalar leaves.

Structural MAP-Elites uses node count, free coefficient count, and
non-algebraic operator count. Semantic MAP-Elites uses one descriptor
coordinate per unlabeled probe row. Predictions are compressed with
arctangent at the training target scale, and cells defines the size
of its CVT. GP retains population_size candidates by training RMSE.
The lexicase modes use generations of population_size proposals
and select parents on training cases. They collect a structural
grid as a passive archive. Set passive_archive=True to
collect the same grid alongside aggregate-error GP.

Novelty-lexicase also selects on output rarity. By default it groups
predictions in 16 fixed bins after arctangent compression using the
training target scale. Pass novelty_binner to map a prediction vector
to a sequence of hashable labels, one per training case. It keeps one
sampled output row per completed generation, up to novelty_history.

For structural or semantic MAP-Elites, template-linkage clusters
homologous tree slots by distance in the template. Learned-linkage
estimates their dependencies with a masked intron symbol. Both
offer each fitted intermediate to the archive and continue the mix
from changes that preserve or improve training error. Subtree
remains the default. The optional total fit cap stops when fewer
than two training evaluations remain.

Supply probes with the same number of columns as X. If provided,
candidates must give finite predictions on every probe in any mode.
Nonlinear bounds, fit_evaluations, and fit_restarts configure
coefficient fitting. Validation and test labels belong outside this
call. The seed controls variation, fitting, and centroid generation.

Definition at line 349 of file _search.py.