-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model configuration redesign #70
Comments
Here is a simple concept sketch: from abc import ABC, abstractstaticmethod
from typing import Optional
class Model(ABC):
def __init__(
self,
obs: str,
pconfigs: dict[str, list[str] | dict],
weights: Optional[str] = None,
) -> None:
self.obs = obs
self._pconfigs = self._get_init_pconfigs(pconfigs)
self.weights = weights
self.params = None
@abstractstaticmethod
def _get_init_pconfigs(pconfigs: dict[str, list[str] | dict]) -> dict:
...
def update_param(self, pname: str, **settings) -> None:
...
def update_variable(self, pname: str, vname: str, **settings):
...
def add_prior(self, pname: str, vname: Optional[str] = None, **settings):
...
class GaussianModel(Model):
def __init__(self, obs: str, mu: list[str] | dict, weights):
super().__init__(obs, {"mu": mu}, weights)
def _get_init_pconfigs(pconfigs: dict[str, list[str] | dict]) -> dict:
...
model = GaussianModel("obs", mu=["intercept", "sdi", "age_group_id"])
model.update_param("mu", transformation="exp")
model.update_variable("mu", "sdi", transformation="spline", knots=[0.0, 0.5, 1.0], degree=3)
model.update_variable("mu", "age_group_id", transformation="factor") Here we use |
We should fix the way we build the model, otherwise it will be complication for both user and developer. We should stick with the "simplified format". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Main objectives
Bonus objective
Capability of saving/loading a model to/from a human readable configuration file (
yaml
).Idea
Use dictionary as the data structure to store model specifications.
Pros:
yaml
fileCons:
Requires
Design dictionary configuration data structure ("simplified form", "comprehensive form") for
Challenges
Variable
containsPrior
andParameter
contains bothVariable
andPrior
Variable
have different transformation, spline and factorPrior
have different types, linear or not, Gaussian or UniformValidate the model configuration
Challenges
The text was updated successfully, but these errors were encountered: