murefi.core
- class murefi.core.ParameterMapping(mapping: DataFrame, *, bounds: dict, guesses: dict)
Bases:
object
- Attributes:
bounds
(lower, upper) tuples for all parameters
coords
Groups the unique parameter ids by the kind of parameter.
guesses
Initial guesses for all parameters
mapping
Dictionary of parameter names or values (floats and strings) for each replicate
ndim
Dimensionality of the parameterization
order
Names of the model parameters
parameters
Maps unique parameters to the names of the corresponding model parameters.
theta_names
Names of unique parameters in the mapping
Methods
Re-creates the DataFrame representation of this parameter mapping.
merge_vectors
(parameter_vectors)Creates a full length (ndim,) parameter vector from a dictionary of parameter vectors.
repmap
(theta_full)Remaps a full parameter vector to a dictionary of replicate-wise parameters.
- as_dataframe() DataFrame
Re-creates the DataFrame representation of this parameter mapping.
It is NOT the identical DataFrame object it was initialized from!
- property bounds: tuple
(lower, upper) tuples for all parameters
- property coords: Dict[str, Tuple[str]]
Groups the unique parameter ids by the kind of parameter.
Keys are in the form f”{pkind}_dim” to avoid conflicting with random variable names (see https://github.com/arviz-devs/arviz/issues/1642).
This dictionary can be used with pymc.Model(coords=coords) to ease creation of vector-shaped priors.
- property guesses: tuple
Initial guesses for all parameters
- property mapping: dict
Dictionary of parameter names or values (floats and strings) for each replicate
- merge_vectors(parameter_vectors: Dict[str, Sequence]) tuple
Creates a full length (ndim,) parameter vector from a dictionary of parameter vectors.
- Returns:
- full_vectuple
the elements from the input parameter vectors in the order specified by .parameters
- property ndim: int
Dimensionality of the parameterization
- property order: tuple
Names of the model parameters
- property parameters: OrderedDict
Maps unique parameters to the names of the corresponding model parameters.
- repmap(theta_full: Sequence | dict) Dict[str, Sequence]
Remaps a full parameter vector to a dictionary of replicate-wise parameters.
- Args:
- theta_full (array-like, dict): full parameter dict, vector or matrix
- when dict:
keys are the unique parameter names (see ParameterMapping.parameters) values are float or Tensors, or numpy.ndarray (N_parametersets,)
- when vector:
(N_parameters,) tuple, list, Tensor or numpy.ndarray with elements being scalar (float/Tensor)
- when matrix:
(N_parameters, N_parametersets) numpy.ndarray
- Returns:
theta_dict (dict): dictionary of replicate-wise parameter vectors/matrices
- property theta_names: Tuple[str]
Names of unique parameters in the mapping