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

Budgeted coefficient fitting with variable projection. More...

Go to the source code of this file.

Classes

class  qdpy.symbolic._fit.CoefficientFit
 One coefficient fit and its measured training evaluation cost. More...
class  qdpy.symbolic._fit._FitLimit
class  qdpy.symbolic._fit._Fitter
class  qdpy.symbolic._fit._FitProblem

Namespaces

namespace  qdpy

Functions

CoefficientFit qdpy.symbolic._fit.fit_expression (Expression expression, X, y, *, nonlinear_bounds=(-20., 20.), int max_evaluations=48, int restarts=4, int|None seed=None)
 Fit free expression coefficients on labeled training data.

Detailed Description

Budgeted coefficient fitting with variable projection.

Definition in file _fit.py.

Function Documentation

◆ fit_expression()

CoefficientFit qdpy.symbolic._fit.fit_expression ( Expression expression,
X,
y,
* ,
nonlinear_bounds = (-20., 20.),
int max_evaluations = 48,
int restarts = 4,
int | None seed = None )

Fit free expression coefficients on labeled training data.

Parameters
expressionThe tree whose free coefficients are to be fitted.
XFinite sample matrix.
yFinite target vector.
nonlinear_boundsShared lower and upper bounds for nonlinear coefficients.
max_evaluationsHard cap on expression evaluations in the fit.
restartsNumber of starts that share the evaluation cap.
seedSeed for nonlinear restart locations.
Returns
A fitted model, when feasible, and the actual evaluation count.
Fit an expression's free scalars on one finite data matrix.

X has shape (samples, variables) and y has one real target per row.
Solve the structurally affine coefficients together by SVD least
squares. For mixed expressions, repeat that solve inside a bounded
SciPy least-squares search over the remaining coefficients (variable
projection). Bounds apply only to nonlinear coefficients.

The evaluation limit includes finite differences and the final check
in the original expression. Restarts divide that budget between
starting points. The seed controls randomized start locations. A
missing model indicates that the fit found no finite solution on all
training rows within the budget. Nonlinear fitting can terminate at a
local optimum.

Definition at line 154 of file _fit.py.