-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
204 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
from preliz.ppls.pymc_io import get_model_information | ||
"""Functions to communicate with Bambi.""" | ||
|
||
|
||
def get_bmb_model_information(model): | ||
def get_pymc_model(model): | ||
if not model.built: | ||
model.build() | ||
pymc_model = model.backend.model | ||
return get_model_information(pymc_model) | ||
return pymc_model | ||
|
||
|
||
def write_bambi_string(new_priors, var_info): | ||
""" | ||
Return a string with the new priors for the Bambi model. | ||
So the user can copy and paste, ideally with none to minimal changes. | ||
""" | ||
header = "{" | ||
header = "{\n" | ||
for key, value in new_priors.items(): | ||
dist_name, dist_params = repr(value).split("(") | ||
dist_params = dist_params.rstrip(")") | ||
size = var_info[key][1] | ||
if size > 1: | ||
header += f'"{key}" : bmb.Prior("{dist_name}", {dist_params}, shape={size}), ' | ||
header += f'"{key}" : bmb.Prior("{dist_name}", {dist_params}, shape={size}),\n' | ||
else: | ||
header += f'"{key}" : bmb.Prior("{dist_name}", {dist_params}), ' | ||
header += f'"{key}" : bmb.Prior("{dist_name}", {dist_params}),\n' | ||
|
||
header = header.rstrip(", ") + "}" | ||
return header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.