Parameter Estimators

class ionworkspipeline.ParameterEstimator(**kwargs: Any)

Base class for all parameter estimators. Parameter estimators find an optimal set of parameters by minimizing an objective function.

Subclasses should override: - run(): Execute the estimation algorithm - Class attributes for capabilities (scalar_output, probabilistic, etc.)

Parameters

**kwargs

Arguments passed to the underlying estimation algorithm.

Extends: ConfigMixin

See also: ParameterEstimator — field-level documentation.

property cost: ObjectiveFunction | None

Cost function used by the estimator.

property gradient: Callable[[ndarray], ndarray]

Objective function gradient (uses finite differences if not provided).

property objective_and_gradient: Callable[[ndarray], tuple[float, ndarray]]

Objective function and gradient (uses finite differences if not provided).

run(x0: ndarray) Any

Run the estimator. Must be implemented by the subclass.

Parameters

x0array_like

Initial guess for the independent variables.

Returns

ParameterEstimatorResult

OptimizationResult for optimizers, PosteriorResult for samplers, RegressionResult for regressors.

set_bounds(bounds: tuple[ndarray, ndarray]) None

Set the bounds using the correct format for the estimator.

Converts from canonical (lower_array, upper_array) to estimator-specific format.

set_data_fit(data_fit: Any) None

Set the associated DataFit object.

set_eq_constraints(eq_constraints: list[Callable]) None

Set equality constraint functions (should evaluate to zero).

Raises NotImplementedError if the estimator doesn’t support custom constraints.

set_gradient(gradient: Callable[[ndarray], ndarray]) None

Set the objective function parameter gradient.

set_ineq_constraints(ineq_constraints: list[Callable]) None

Set inequality constraint functions (should evaluate to > 0).

Raises NotImplementedError if the estimator doesn’t support custom constraints.

set_objective(objective: Callable[[ndarray], float | ndarray]) None

Set the objective function to be minimized.

set_objective_and_gradient(objective_and_gradient: Callable[[ndarray], tuple[float, ndarray]]) None

Set the objective function and its parameter gradient.

set_residual_jacobian(jacobian: Callable[[ndarray], ndarray]) None

Set an analytic residual Jacobian J(x) = d(residual)/dx.

jacobian(x) must return an array of shape (n_residuals, n_params). Least-squares optimizers (ScipyLeastSquares, ScipyLsqLinear) use it instead of finite differences when present.

to_config() dict

Convert the parameter estimator back to parser configuration format.

Returns

dict

Configuration dictionary that can be passed to parse_optimizer

class ionworkspipeline.parameter_estimators.Chain(*estimators)

Chain of estimators to be run in sequence, where the output of one estimator is the initial guess for the next estimator.

Parameters

*estimatorslist of estimator objects

The estimators to be run in sequence.

Extends: list

property cost

If all estimators have the same default cost function, return it. Otherwise, raise an error.

run(x0)

Optimize the objective function by running each estimator in sequence.

Parameters

x0array_like

Initial guess for the independent variables.

Returns

resionworkspipeline.estimatorResult

The result of the optimization.