eqdisco.equation.Equation#

class eqdisco.equation.Equation(expr, feature_names=None, metrics=None, meta=None)[source]#

Bases: object

A symbolic model \(\hat y = f(\mathbf{x};\boldsymbol\theta)\).

Parameters:
exprExpression

The model, with fitted parameters.

feature_namessequence of str, optional

Names of the input variables (column order of X).

metricsdict, optional

Training (or validation) metrics, e.g. {"mse": ..., "r2": ...}.

metadict, optional

Free-form metadata (method, generation found, seed, …).

property complexity#

Number of nodes (use complexity_of() for other measures).

evaluate_metrics(X, y)[source]#

All regression metrics of regression_metrics() on (X, y).

classmethod from_string(text, feature_names=None, **kw)[source]#

Parse an equation such as "3.2*x0*exp(-0.5*x1)".

latex(digits=4, lhs=None)[source]#

LaTeX string, e.g. eq.latex(lhs="y") gives y = ....

predict(X)[source]#

Model output for every row of X (array or DataFrame).

refit(X, y, method='lm', restarts=0, random_state=None, sample_weight=None)[source]#

Re-estimate the parameters by nonlinear least squares (structure unchanged).

rounded(digits=4)[source]#

A copy with every parameter rounded to digits significant digits.

score(X, y)[source]#

\(R^2\) on (X, y).

sympy(simplify=False, digits=None)[source]#

SymPy form (optionally simplified with sympy.simplify()).

to_dict()[source]#

Lossless JSON-friendly dictionary (Equation.from_dict restores it).

property variables#

Names of the variables that occur in the equation.