fit_minimize
- pmrf.fitting.fit_minimize(model: ModelT, data: ndarray | Array | Network | NetworkCollection, frequency: Frequency | None = None, solver: AbstractUnconstrainedMinimizer | AbstractBoundedMinimizer | None = None, *, features: str | list[str] | Callable = 's', inference: str = 'frequentist', loss: Callable[[Array, Array], Array] = None, likelihood: Callable[[Array], AbstractDistribution] = None, noise: Param | Callable[[Array], Array] = None, discrepancy: Callable[[Array, Array], AbstractDistribution] | None = None, temperature: float = None, **kwargs) FitResult[ModelT]
Fits an RF model to measured data using non-linear optimization.
This high-level function handles data formatting (e.g., extracting arrays from the scikit-rf Networks) and forwards to
pmrf.optimize.minimize().- Parameters:
model (Model) – The RF model to fit.
data (np.ndarray | jnp.ndarray | skrf.Network | NetworkCollection) – The data to fit to. Can either be a JAX array, a
skrf.Network, or apmrf.NetworkCollection.frequency (Frequency | None, default=None) – The frequency sweep. Required if data is a raw array; otherwise automatically extracted from the Network object.
solver (AbstractMinimizer, optional) – The optimizer to use. See
pmrf.optimizefor available solvers.features (str | list[str] | Callable[[Model, Frequency], jnp.ndarray], default='s') – The RF features to fit. Can either be function, a callable PyTree with optional parameters, or a string, in which case a feature evaluator is created (see
pmrf.evaluators.Feature). Defaults to all S-parameters.inference (str) – The type of inference to use, either ‘frequentist’ or ‘bayesian’. See loss and likelihood for more information.
loss (str | Callable, optional) – A loss function between the model prediction and the data. Can be a function or a callable PyTree with optional parameters. Used to internally create a
pmrf.evaluators.TargetLossevaluator. Mutually exclusive with likelihood. If neither loss nor likelihood is passed,pmrf.losses.RMSELossis used for loss if inference is ‘frequentist’, otherwisepmrf.likelihoods.GaussianLikelihoodis used for likelihood. Seepmrf.lossesfor common losses.likelihood (str | Callable, optional) – A likelihood model representing the probability of observing the data. Can be a function or a callable PyTree with optional parameters. Used to internally create a
pmrf.evaluators.NegativeLogLikelihoodorpmrf.evaluators.NegativeLogPosteriorevaluator. Mutually exclusive with loss. If neither loss nor likelihood is passed,pmrf.losses.RMSELossis used for loss if inference is ‘frequentist’, otherwisepmrf.likelihoods.GaussianLikelihoodis used for likelihood. Seepmrf.lossesfor common losses.noise (prf.Param | Callable[[jnp.ndarray], jnp.ndarray], optional) – Likelihood noise (variance), either a fixed parameter, or a callable that accepts a model prediction (in event space) and returns noise parameters for a Gaussian likelihood. Mutually exclusive with likelihood. For the function case, can be a callable PyTree with optional parameters. See
pmrf.noise_modelsfor built-in noise models. Defaults to None, in which case uniform variance from 0.0 to 0.1 is constructed internally. Only allowed if likelihood is passed and/or inference is ‘bayesian’.discrepancy (Callable[[jnp.ndarray, jnp.ndarray], jnp.ndarray | dist.AbstractDistribution], optional) – A discrepancy model, which caters for the discrepancy between the model and measured data. Can either be a function, or a callable PyTree with optional parameters. To use a Gaussian process as a discrepancy model, see
pmrf.discrepancy_models.GaussianProcess. Only allowed if likelihood is passed and/or inference is ‘bayesian’.temperature (float, optional) – The temperature value for generalized Bayesian optimization. Only allowed if inference is ‘bayesian’ and loss is not None. Defaults to 1.0 internally.
**kwargs (dict) – Additional keyword arguments passed to
pmrf.optimize.minimize()and then underlying solver.
- Returns:
The optimization result containing the fitted Model.
- Return type: