-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test util for setting fake data in CLV models
- Loading branch information
1 parent
6f7a3d4
commit 3e92610
Showing
5 changed files
with
33 additions
and
26 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Union | ||
|
||
from arviz import InferenceData | ||
from xarray import Dataset | ||
|
||
from pymc_marketing.clv.models import CLVModel | ||
|
||
|
||
def set_model_fit(model: CLVModel, fit: Union[InferenceData, Dataset]): | ||
if isinstance(fit, InferenceData): | ||
assert "posterior" in fit.groups() | ||
else: | ||
fit = InferenceData(posterior=fit) | ||
if model.model is None: | ||
model.build_model() | ||
model.idata = fit | ||
model.idata.add_groups(fit_data=model.data.to_xarray()) | ||
model.set_idata_attrs(fit) |