fit

fit(model, data, frequency=None, solver=ScipyMinimizer(options={}), *, features='s', loss_fn=LogMSELoss(multioutput='uniform_average', name=None), multioutput=None, scale_fn=None, transform=None, **kwargs)[source]

Fits an RF model to measured data using frequentist optimization.

This high-level function handles data format coercion (e.g., extracting arrays from scikit-rf Networks) and automatically composes the necessary evaluator metrics.

Parameters:
  • model (Model) – The model to fit.

  • data (jnp.ndarray | skrf.Network | NetworkCollection) – The target data to fit against. Can be raw JAX arrays or standard Touchstone networks.

  • frequency (Frequency | None, default=None) – The frequency sweep. Required if data is a raw array; otherwise automatically extracted from the Network object.

  • solver (Solver, default=ScipyMinimizer()) – The optimization algorithm backend.

  • features (str | list[str] | Callable, default='s') – The specific circuit feature to fit (e.g., ‘s’, ‘s11_db’, ‘y’).

  • loss_fn (str | Callable, default=LogMSELoss()) – The loss function between the model predictionand the data. Can be a string for a lookup into :data:pmrf.math.LOSS_LOOKUP (e.g., ‘mse’, ‘mae’, ‘rmse’), a callable taking (y_true, y_pred), or a callable PyTree. See :mod:pmrf.losses for common losses.

  • multioutput (Aggregation, optional) – An additional key-word parameter to optionally pass to loss_fn indicating how to aggregate outputs. For the default of None, the argument is not passed.

  • scale_fn (str | Callable, default=None) – A scaling to apply to the output metric after aggregation. Can be a string for a lookup into :data:pmrf.math.CONVERSION_LOOKUP.

  • transform (ParameterTransform, default=None) – An invertible transformation to apply to all model parameters before optimization.

  • **kwargs (dict) – Additional keyword arguments passed to the underlying solver.

Returns:

The optimization result containing the newly fitted Model.

Return type:

OptimizeResult