pmrf.fitting.BayesianFitter
- class pmrf.fitting.BayesianFitter(model, measured, *args, frequency=None, features=None, likelihood_kind='gaussian', likelihood_params=None, **kwargs)[source]
Bases:
BaseFitterA base class for Bayesian fitting methods.
This class extends BaseFitter by adding the concept of a likelihood function.
Initializes the BayesianFitter.
- Args:
- model (Model):
The parametric pmrf model to be fitted.
- measured (skrf.Network | list[skrf.Network]):
The measured network data to fit the model against.
- frequency (skrf.Frequency | None, optional):
The frequency axis to perform the fit on. Defaults to None.
- features (FeatureT | FeatureListT | None = None, optional):
The features to extract for comparison. Note that note all features make sense for all likelihoods, but no error checking is done for this. Defaults to None, in which case real and imaginary feature for all model ports are used.
- likelihood_kind (str, optional):
The kind of likelihood to use. Defaults to “gaussian” for a one-dimensional Gaussian likelihood requiring a single likelihood parameter ‘sigma’. Can also be “multivariate_gaussian”, in which case either multiple standard deviations ‘sigma_0’, ‘sigma_1’, …, ‘sigma_N’ may be passed, where N is the number of features, or an arbitrary number of arbitrarily named likelihood parameters may be passed, along with a list of strings feature_sigmas of size N containing the names of the likelihood parameters to use for each feature.
- likelihood_params (dict[str, Parameter], optional):
A dictionary of likelihood parameters to use for the likelihood function.
- train_posteriors (bool, optional):
Whether or not model posteriors should be trained and set for the fitted model.
- Parameters:
model (Model)
measured (Network | NetworkCollection)
frequency (Frequency | None)
features (str | tuple[str, str] | tuple[str, str, tuple[int, int]] | Sequence[str | tuple[str, str] | tuple[str, str, tuple[int, int]]] | dict[str, str | tuple[str, str] | tuple[str, str, tuple[int, int]] | Sequence[str | tuple[str, str] | tuple[str, str, tuple[int, int]]]] | None)
likelihood_kind (str | None)
likelihood_params (dict[str, Parameter])
- __init__(model, measured, *args, frequency=None, features=None, likelihood_kind='gaussian', likelihood_params=None, **kwargs)[source]
Initializes the BayesianFitter.
- Args:
- model (Model):
The parametric pmrf model to be fitted.
- measured (skrf.Network | list[skrf.Network]):
The measured network data to fit the model against.
- frequency (skrf.Frequency | None, optional):
The frequency axis to perform the fit on. Defaults to None.
- features (FeatureT | FeatureListT | None = None, optional):
The features to extract for comparison. Note that note all features make sense for all likelihoods, but no error checking is done for this. Defaults to None, in which case real and imaginary feature for all model ports are used.
- likelihood_kind (str, optional):
The kind of likelihood to use. Defaults to “gaussian” for a one-dimensional Gaussian likelihood requiring a single likelihood parameter ‘sigma’. Can also be “multivariate_gaussian”, in which case either multiple standard deviations ‘sigma_0’, ‘sigma_1’, …, ‘sigma_N’ may be passed, where N is the number of features, or an arbitrary number of arbitrarily named likelihood parameters may be passed, along with a list of strings feature_sigmas of size N containing the names of the likelihood parameters to use for each feature.
- likelihood_params (dict[str, Parameter], optional):
A dictionary of likelihood parameters to use for the likelihood function.
- train_posteriors (bool, optional):
Whether or not model posteriors should be trained and set for the fitted model.
- Parameters:
model (Model)
measured (Network | dict[str, Network])
frequency (Frequency | None)
features (str | tuple[str, str] | tuple[str, str, tuple[int, int]] | Sequence[str | tuple[str, str] | tuple[str, str, tuple[int, int]]] | dict[str, str | tuple[str, str] | tuple[str, str, tuple[int, int]] | Sequence[str | tuple[str, str] | tuple[str, str, tuple[int, int]]]] | None)
likelihood_kind (str | None)
likelihood_params (dict[str, Parameter] | None)
- Return type:
None
Methods
__delattr__(name, /)Implement delattr(self, name).
__dir__()Default dir() implementation.
__eq__(value, /)Return self==value.
__format__(format_spec, /)Default object formatter.
__ge__(value, /)Return self>=value.
__getattribute__(name, /)Return getattr(self, name).
__gt__(value, /)Return self>value.
__hash__()Return hash(self).
__init__(model, measured, *args[, ...])Initializes the BayesianFitter.
__init_subclass__This method is called when a class is subclassed.
__le__(value, /)Return self<=value.
__lt__(value, /)Return self<value.
__ne__(value, /)Return self!=value.
__new__(**kwargs)__reduce__()Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__()Return repr(self).
__setattr__(name, value, /)Implement setattr(self, name, value).
__sizeof__()Size of object in memory, in bytes.
__str__()Return str(self).
__subclasshook__Abstract classes can override this to customize issubclass().
_flat_param_names()_likelihood_param_names()_make_feature_function([as_numpy])_make_gaussian_log_likelihood_fn()_make_log_likelihood_fn([as_numpy])_make_log_prior_fn([as_numpy])_make_multivariate_gaussian_log_likelihood_fn()_make_prior_transform_fn([as_numpy])_model_param_names()_settings([solver_kwargs, fitter_kwargs])run(*args, **kwargs)Executes the fitting algorithm.
Attributes
__abstractmethods____annotations____dict____doc____module____slots____weakref__list of weak references to the object (if defined)
_abc_impl- property num_params: int
- property num_model_params: int
- property num_likelihood_params: int