Priors¶
Prior schemas used as regularizers in fitting objectives.
Schemas for priors.
- class ionworks.pipeline.priors.Prior(name=None, distribution=None, regularizer_weight=None, *, type: Literal['Prior'] = 'Prior')[source]
Bases:
RegularizerRegularization prior on a parameter.
- Parameters:
name (str or list of str) – Parameter name(s) the prior applies to.
distribution (ionworks.pipeline.stats.Distribution) – Probability distribution describing prior beliefs about the parameter(s).
regularizer_weight (float, optional) – Weight applied to the prior’s contribution to the cost. Default is 1.0.
Examples
>>> prior = iw.pipeline.priors.Prior("Q_pe", iw.pipeline.stats.Normal(mean=3.0, std=0.2)) >>> fit = iw.pipeline.DataFit( ... objectives={"ocp": iw.pipeline.objectives.OCPHalfCell( ... electrode="positive", data_input="path/to/ocp.csv", ... )}, ... priors={"Q_pe": prior}, ... )
- type: Literal['Prior']
- distribution: Annotated[Dirichlet | LogNormal | MultivariateLogNormal | MultivariateNormal | Normal | PointMass | Uniform, FieldInfo(annotation=NoneType, required=True, discriminator='distribution'), WrapValidator(func=_resolve_distribution, json_schema_input_type=PydanticUndefined)]
- model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None
This function is meant to behave like a BaseModel method to initialize private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Args:
self: The BaseModel instance. context: The context.