fit_sample
- pmrf.fitting.fit_sample(model: ModelT, data: Array | Network | NetworkCollection, frequency: Frequency | None = None, solver: AbstractJointSampler | AbstractSplitSampler | AbstractHypercubeSampler | None = None, *, features: str | list[str] | Callable = 's', likelihood: Callable[[Array], AbstractDistribution] | list[Callable[[Array], AbstractDistribution]] = None, noise: Param | Callable[[Array], Array] = None, loss: Callable[[Array, Array], Array] = None, discrepancy: Callable[[Array, Array], AbstractDistribution] | None = None, temperature: float = None, **kwargs) FitResult[ModelT]
Conditions an RF model on measured data using Bayesian sampling.
This high-level function handles data format formatting (e.g., extracting arrays from scikit-rf Networks) and forwards to
pmrf.infer.sample().- Parameters:
model (Model) – The RF model to fit.
data (jnp.ndarray | skrf.Network | NetworkCollection) – The data to condition on. 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 (AbstractSampler, optional) – The sampler to use. See
pmrf.inferfor available solvers.features (str | list[str] | Callable[[Model, Frequency], jnp.ndarray], default='s') – The RF features to condition on. 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.likelihood (Callable[[jnp.ndarray], AbstractDistribution], optional) – The likelihood model, which accepts a model prediction (in event space) and returns a distribution representing the probability of observing the data. Can be a function or a callable PyTree with optional parameters. See
pmrf.likelihoodsfor common likelihoods. Mutually exclusive with loss.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 and loss. 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.loss (Callable[[jnp.ndarray, jnp.ndarray], jnp.ndarray], optional) – A loss function between the model prediction and the data to construct a Gibbs measure. Can be a function or a callable PyTree with optional parameters. Mutually exclusive with likelihood and noise. If neither loss nor likelihood is passed, a
pmrf.likelihoods.GaussianLikelihoodis constructed.discrepancy (Callable[[jnp.ndarray, jnp.ndarray], jnp.ndarray | 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.discrepancys.GaussianProcess.temperature (float, optional) – The temperature value for generalized Bayesian optimization. Only used when loss is not None. Defaults to 1.0 internally.
**kwargs (dict) – Additional keyword arguments passed to the underlying solver.
- Returns:
The result containing the model maximum likelikhood estimate model with an empirical posterior.
- Return type: